diff --git a/en/application-dev/Readme-EN.md b/en/application-dev/Readme-EN.md index a2c710bd4b38303f79fb8835d70693f87b4146f3..36d653078e36493e3927053cb636ba48062213d9 100644 --- a/en/application-dev/Readme-EN.md +++ b/en/application-dev/Readme-EN.md @@ -36,8 +36,8 @@ - [Device Usage Statistics](device-usage-statistics/Readme-EN.md) - [DFX](dfx/Readme-EN.md) - [Internationalization](internationalization/Readme-EN.md) - - - - [Using Native APIs in Application Projects](napi/napi-guidelines.md) + - [OpenHarmony IDL Specifications and User Guide](IDL/idl-guidelines.md) + - [Using Native APIs in Application Projects](napi/Readme-EN.md) - Tools - [DevEco Studio (OpenHarmony) User Guide](quick-start/deveco-studio-user-guide-for-openharmony.md) - Hands-On Tutorials diff --git a/en/application-dev/connectivity/ipc-rpc-development-guideline.md b/en/application-dev/connectivity/ipc-rpc-development-guideline.md index a6fcb7226b83ae4b4e8aaf82d1fa84bd1291001e..03019858805cff17ef97b4c7227ee5c86947536b 100644 --- a/en/application-dev/connectivity/ipc-rpc-development-guideline.md +++ b/en/application-dev/connectivity/ipc-rpc-development-guideline.md @@ -46,7 +46,7 @@ IPC/RPC enables a proxy and a stub that run on different processes to communicat 1. Define the IPC interface **ITestAbility**. - **ITestAbility** inherits the IPC base class **IRemoteBroker** and defines descriptors, functions, and message code. The functions need to be implemented on both the proxy and stub. + **ITestAbility** inherits the IPC base class **IRemoteBroker** and defines descriptors, functions, and message code. The functions need to be implemented on both the proxy and stub. ``` class ITestAbility : public IRemoteBroker { diff --git a/en/application-dev/database/database-distributedobject-guidelines.md b/en/application-dev/database/database-distributedobject-guidelines.md index 4ff96ed5e1b1427d87a35043d2ee53cb686c3698..a3f5d13676287d1a7b54a4e16d8705ac255c1ec6 100644 --- a/en/application-dev/database/database-distributedobject-guidelines.md +++ b/en/application-dev/database/database-distributedobject-guidelines.md @@ -107,7 +107,7 @@ The following example shows how to implement a distributed data object synchroni }); } } - + // To refresh the page in changeCallback, correctly bind (this) to the changeCallback. local_object.on("change", this.changeCallback.bind(this)); ``` @@ -171,7 +171,7 @@ The following example shows how to implement a distributed data object synchroni ```js local_object.setSessionId(""); ``` -## Development Example +## Samples The following example is provided for you to better understand the development of distributed data objects: @@ -179,4 +179,4 @@ The following example is provided for you to better understand the development o When an event of the Notepad app occurs on a device, such as a note is added, the tile or content of a note is changed, or the event list is cleared, the change will be synchronized to other devices in the trusted network. - + diff --git a/en/application-dev/database/database-mdds-guidelines.md b/en/application-dev/database/database-mdds-guidelines.md index d59fd3904ae8d8606f0ab254d78b9a4f03be3dc8..ce4f1ad79d78e0bcb5b2ef5d184894149a61ed20 100644 --- a/en/application-dev/database/database-mdds-guidelines.md +++ b/en/application-dev/database/database-mdds-guidelines.md @@ -177,5 +177,5 @@ The following uses a single KV store as an example to describe the development p ``` ## Samples The following samples are provided to help you better understand the distributed data development: -- [`KvStore`: distributed database (eTS) (API8)](https://gitee.com/openharmony/app_samples/tree/master/data/Kvstore) -- [Distributed Database](https://gitee.com/openharmony/codelabs/tree/master/Data/JsDistributedData) +- [`KvStore`: Distributed Data Management (eTS) (API8)](https://gitee.com/openharmony/app_samples/tree/master/data/Kvstore) +- [Distributed Data Service](https://gitee.com/openharmony/codelabs/tree/master/Data/JsDistributedData) diff --git a/en/application-dev/database/database-relational-guidelines.md b/en/application-dev/database/database-relational-guidelines.md index d23f0c0c5735f5fdd91b16f67705af26523ca550..d43b11ff62e73d65de6d77623641b7748a82c824 100644 --- a/en/application-dev/database/database-relational-guidelines.md +++ b/en/application-dev/database/database-relational-guidelines.md @@ -116,8 +116,8 @@ The RDB provides **RdbPredicates** for you to set database operation conditions. A result set can be regarded as a row of data in the queried results. It allows you to traverse and access the data you have queried. The following table describes the external APIs of **ResultSet**. -> ![icon-notice.gif](../public_sys-resources/icon-notice.gif) **NOTICE**
-> After a result set is used, you must call the **close()** method to close it explicitly.** +> ![icon-notice.gif](public_sys-resources/icon-notice.gif) **NOTICE**
+> After a result set is used, you must call the **close()** method to close it explicitly. **Table 7** APIs for using the result set @@ -306,3 +306,8 @@ You can obtain the distributed table name for a remote device based on the local let tableName = rdbStore.obtainDistributedTableName(deviceId, "test"); let resultSet = rdbStore.querySql("SELECT * FROM " + tableName) ``` +## Samples +The following samples are provided for you to better understand the RDB development: +- [`Rdb`: eTS RDB (API8)](https://gitee.com/openharmony/app_samples/tree/master/data/Rdb) +- [`DistributedRdb`: eTS Distributed Relational Database (API8)](https://gitee.com/openharmony/app_samples/tree/master/data/DistributedRdb) +- [Relational Database](https://gitee.com/openharmony/codelabs/tree/master/Data/JSRelationshipData) diff --git a/en/application-dev/internationalization/intl-guidelines.md b/en/application-dev/internationalization/intl-guidelines.md index 76c00eb557816681efb54e9e7ec5d0a3754471b6..64869566ea47e588dc18271eee55c90b5784763a 100644 --- a/en/application-dev/internationalization/intl-guidelines.md +++ b/en/application-dev/internationalization/intl-guidelines.md @@ -4,12 +4,12 @@ This development guide describes how to use i18n APIs that are defined in ECMA 4 ## Setting Locale Information -[Locale](../reference/apis/js-apis-intl.md) APIs are used to maximize or minimize locale information. +Use [Locale](../reference/apis/js-apis-intl.md) APIs to maximize or minimize locale information. ### Available APIs - | Module | API | Description | +| Module | API | Description | | -------- | -------- | -------- | | ohos.intl | constructor()8+ | Instantiates a **Locale** object. | | ohos.intl | constructor(locale?: string, options?: options) | Instantiates a **Locale** object based on the locale parameter and options. | @@ -20,8 +20,8 @@ This development guide describes how to use i18n APIs that are defined in ECMA 4 ### How to Develop -1. Instantiate a **Locale** object. - Create a **Locale** object using the **Locale** constructor. This method receives a string representing the locale and an optional [Attributes](../reference/apis/js-apis-intl.md) list (**intl** is the name of the imported module). +1. Instantiate a **Locale** object.
+ Create a **Locale** object by using the **Locale** constructor. This method receives a string representing the locale and an optional [Attributes](../reference/apis/js-apis-intl.md) list. In the code below, **intl** is the name of the imported module. ``` @@ -30,22 +30,22 @@ This development guide describes how to use i18n APIs that are defined in ECMA 4 var localeObj = new intl.Locale(locale, options); ``` -2. Obtain the string representing a **Locale** object. - Call the **toString** method to obtain the string representing a **Locale** object, including the language, region, and other options. +2. Obtain the string representing a **Locale** object.
+ Call the **toString** method to obtain the string representing a **Locale** object, which includes the language, region, and other options. ``` var localeStr = localeObj.toString(); ``` -3. Maximize locale information. - Call the **maximize** method to maximize locale information; that is, supplement the missing script and region information. +3. Maximize locale information.
+ Call the **maximize** method to maximize locale information; that is, supplement the missing script and region information. ``` var maximizedLocale = localeObj.maximize(); ``` -4. Minimize locale information. - Call the **minimize** method to minimize locale information; that is, delete the unnecessary script and region information. +4. Minimize locale information.
+ Call the **minimize** method to minimize locale information; that is, delete the unnecessary script and region information. ``` var minimizedLocale = localeObj.minimize(); @@ -54,12 +54,12 @@ This development guide describes how to use i18n APIs that are defined in ECMA 4 ## Formatting the Date and Time -[DateTimeFormat](../reference/apis/js-apis-intl.md) APIs are used to format the date and time for a specific locale. +Use [DateTimeFormat](../reference/apis/js-apis-intl.md) APIs to format the date and time for a specific locale. ### Available APIs - | Module | API | Description | +| Module | API | Description | | -------- | -------- | -------- | | ohos.intl | constructor()8+ | Creates a **DateTimeFormat** object. | | ohos.intl | constructor(locale: string \| Array<string>, options?: DateTimeOptions) | Creates a **DateTimeFormat** object and sets the locale and other formatting-related attributes. | @@ -70,31 +70,31 @@ This development guide describes how to use i18n APIs that are defined in ECMA 4 ### How to Develop -1. Instantiate a **DateTimeFormat** object. - Use the default constructor of **DateTimeFormat** to obtain the system default locale by accessing the system language and region settings, and set it as the locale in the **DateTimeFormat** object (**intl** is the name of the imported module). +1. Instantiate a **DateTimeFormat** object.
+ Use the default constructor of **DateTimeFormat** to obtain the system default locale by accessing the system language and region settings, and set it as the locale in the **DateTimeFormat** object. In the code below, **intl** is the name of the imported module. ``` var dateTimeFormat = new intl.DateTimeFormat(); ``` - Alternatively, use your own locale and formatting parameters to create a **DateTimeFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [DateTimeOptions](../reference/apis/js-apis-intl.md). + Alternatively, use your own locale and formatting parameters to create a **DateTimeFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [DateTimeOptions](../reference/apis/js-apis-intl.md). ``` var options = {dateStyle: "full", timeStyle: "full"}; var dateTimeFormat = new intl.DateTimeFormat("zh-CN", options); ``` -2. Format the date and time. - Use the **format** method of **DateTimeFormat** to format a **Date** object. A string is returned as the formatting result. +2. Format the date and time.
+ Use the **format** method of **DateTimeFormat** to format a **Date** object. This method returns a string representing the formatting result. ``` Date date = new Date(); var formatResult = dateTimeFormat.format(date); ``` -3. Format a period. - Use the **formatRange** method of **DateTimeFormat** to format a period. This method requires the input of two **Date** objects, which respectively indicate the start date and end date of a period. A string is returned as the formatting result. +3. Format a period.
+ Use the **formatRange** method of **DateTimeFormat** to format a period. This method requires input of two **Date** objects, which respectively indicate the start date and end date of a period. This method returns a string representing the formatting result. ``` Date startDate = new Date(); @@ -102,8 +102,8 @@ This development guide describes how to use i18n APIs that are defined in ECMA 4 var formatResult = dateTimeFormat.formatRange(startDate, endDate); ``` -4. Access the attributes of the **DateTimeFormat** object. - The **resolvedOptions** method of **DateTimeFormat** returns an object that contains all related attributes and values of the **DateTimeFormat** object. +4. Obtain attributes of the **DateTimeFormat** object.
+ The **resolvedOptions** method of **DateTimeFormat** returns an object that contains all related attributes and values of the **DateTimeFormat** object. ``` var options = dateTimeFormat.resolvedOptions(); @@ -112,12 +112,12 @@ This development guide describes how to use i18n APIs that are defined in ECMA 4 ## Number Formatting -[NumberFormat](../reference/apis/js-apis-intl.md) APIs are used to format a number for a specific locale. +Use [NumberFormat](../reference/apis/js-apis-intl.md) APIs to format a number for a specific locale. ### Available APIs - | Module | API | Description | +| Module | API | Description | | -------- | -------- | -------- | | ohos.intl | constructor()8+ | Creates a **NumberFormat** object. | | ohos.intl | constructor(locale: string \| Array<string>, options?: NumberOptions) | Creates a **NumberFormat** object and sets the locale and other formatting-related attributes. | @@ -127,31 +127,31 @@ This development guide describes how to use i18n APIs that are defined in ECMA 4 ### How to Develop -1. Instantiate a **NumberFormat** object. - Use the default constructor of **NumberFormat** to obtain the system default locale by accessing the system language and region settings and set it as the locale in the **NumberFormat** object (**intl** is the name of the imported module). +1. Instantiate a **NumberFormat** object.
+ Use the default constructor of **NumberFormat** to obtain the system default locale by accessing the system language and region settings, and set it as the locale in the **NumberFormat** object. In the code below, **intl** is the name of the imported module. ``` var numberFormat = new intl.NumberFormat(); ``` - Alternatively, use your own locale and formatting parameters to create a **NumberFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [NumberOptions](../reference/apis/js-apis-intl.md). + Alternatively, use your own locale and formatting parameters to create a **NumberFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [NumberOptions](../reference/apis/js-apis-intl.md). ``` var options = {compactDisplay: "short", notation: "compact"}; var numberFormat = new intl.NumberFormat("zh-CN", options); ``` -2. Format a number. - Use the **format** method of **NumberFormat** to format a number. A string is returned as the formatting result. +2. Format a number.
+ Use the **format** method of **NumberFormat** to format a number. A string is returned as the formatting result. ``` var number = 1234.5678 var formatResult = numberFormat.format(number); ``` -3. Access the attributes of the **NumberFormat** object. - The **resolvedOptions** method of NumberFormat returns an object that contains all related attributes and values of the **NumberFormat** object. +3. Obtain attributes of the **NumberFormat** object.
+ The **resolvedOptions** method of NumberFormat returns an object that contains all related attributes and values of the **NumberFormat** object. ``` var options = numberFormat.resolvedOptions(); @@ -160,12 +160,12 @@ This development guide describes how to use i18n APIs that are defined in ECMA 4 ## String Sorting -Users in different regions have different requirements for string sorting. [Collator](../reference/apis/js-apis-intl.md) APIs are used to sort strings based on a specific locale. +Use [Collator](../reference/apis/js-apis-intl.md) APIs to sort strings based on a specific locale. Users in different regions have different preferences for string sorting. ### Available APIs - | Module | API | Description | +| Module | API | Description | | -------- | -------- | -------- | | ohos.intl | constructor()8+ | Creates a **Collator** object. | | ohos.intl | constructor(locale: string \| Array<string>, options?: CollatorOptions)8+ | Creates a **Collator** object and sets the locale and other related attributes. | @@ -175,22 +175,22 @@ Users in different regions have different requirements for string sorting. [Coll ### How to Develop -1. Instantiate a **Collator** object. - Use the default constructor of **Collator** to obtain the system default locale by accessing the system language and region settings and set it as the locale in the **Collator** object (**intl** is the name of the imported module). +1. Instantiate a **Collator** object.
+ Use the default constructor of **Collator** to obtain the system default locale by accessing the system language and region settings, and set it as the locale in the **Collator** object. In the code below, **intl** is the name of the imported module. ``` var collator = new intl.Collator(); ``` - Alternatively, use your own locale and formatting parameters to create a **Collator** object. For a full list of parameters, see [CollatorOptions](../reference/apis/js-apis-intl.md). + Alternatively, use your own locale and formatting parameters to create a **Collator** object. For a full list of parameters, see [CollatorOptions](../reference/apis/js-apis-intl.md). ``` var collator= new intl.Collator("zh-CN", {localeMatcher: "best fit", usage: "sort"}; ``` -2. Compare two strings. - Use the **compare** method of **Collator** to compare two input strings. This method returns a value as the comparison result. The return value **-1** indicates that the first string is shorter than the second string, the return value **1** indicates that the first string is longer than the second string, and the return value **0** indicates that the two strings are of equal lengths. +2. Compare two strings.
+ Use the **compare** method of **Collator** to compare two input strings. This method returns a value as the comparison result. The return value **-1** indicates that the first string is shorter than the second string, the return value **1** indicates that the first string is longer than the second string, and the return value **0** indicates that the two strings are of equal lengths. ``` var str1 = "first string"; @@ -198,8 +198,8 @@ Users in different regions have different requirements for string sorting. [Coll var compareResult = collator.compare(str1, str2); ``` -3. Access the attributes of the **Collator** object. - The **resolvedOptions** method of **Collator** returns an object that contains all related attributes and values of the **Collator** object. +3. Obtain attributes of the **Collator** object.
+ The **resolvedOptions** method of **Collator** returns an object that contains all related attributes and values of the **Collator** object. ``` var options = collator.resolvedOptions(); @@ -208,12 +208,12 @@ Users in different regions have different requirements for string sorting. [Coll ## Determining the Singular-Plural Type -According to grammars in certain languages, the singular or plural form of a noun depends on the number prior to the noun. [PluralRules](../reference/apis/js-apis-intl.md) APIs are used to determine the singular-plural type for a specific locale. +Use [PluralRules](../reference/apis/js-apis-intl.md) APIs to determine the singular-plural type for a specific locale. According to the grammar of certain languages, the singular or plural form of a noun depends on its preceding number. ### Available APIs - | Module | API | Description | +| Module | API | Description | | -------- | -------- | -------- | | ohos.intl | constructor()8+ | Creates a **PluralRules** object. | | ohos.intl | constructor(locale: string \| Array<string>, options?: PluralRulesOptions)8+ | Creates a **PluralRules** object and sets the locale and other related attributes. | @@ -222,22 +222,22 @@ According to grammars in certain languages, the singular or plural form of a nou ### How to Develop -1. Instantiate a **PluralRules** object. - Use the default constructor of **PluralRules** to obtain the system default locale by accessing the system language and region settings and set it as the locale in the **PluralRules** object (**intl** is the name of the imported module). +1. Instantiate a **PluralRules** object.
+ Use the default constructor of **PluralRules** to obtain the system default locale by accessing the system language and region settings, and set it as the locale in the **PluralRules** object. In the code below, **intl** is the name of the imported module. ``` var pluralRules = new intl.PluralRules(); ``` - Alternatively, use your own locale and formatting parameters to create a **PluralRules** object. For a full list of parameters, see [PluralRulesOptions](../reference/apis/js-apis-intl.md). + Alternatively, use your own locale and formatting parameters to create a **PluralRules** object. For a full list of parameters, see [PluralRulesOptions](../reference/apis/js-apis-intl.md). ``` var plurals = new intl.PluralRules("zh-CN", {localeMatcher: "best fit", type: "cardinal"}; ``` -2. Determine the singular or plural category. - Use the **select** method of **PluralRules** to determine the singular-plural type for an input number. This method returns a string as the category of the input number, which can be any of the following: **zero**, **one**, **two**, **few**, **many**, and **other**. +2. Determine the singular or plural category.
+ Use the **select** method of **PluralRules** to determine the singular-plural type for an input number. This method returns a string as the category of the input number, which can be any of the following: **zero**, **one**, **two**, **few**, **many**, and **other**. ``` var number = 1234.5678 @@ -247,12 +247,12 @@ According to grammars in certain languages, the singular or plural form of a nou ## Formatting Relative Time -[RelativeTimeFormat](../reference/apis/js-apis-intl.md) APIs are used to format the relative time for a specific locale. +Use [RelativeTimeFormat](../reference/apis/js-apis-intl.md) APIs to format the relative time for a specific locale. ### Available APIs - | Module | API | Description | +| Module | API | Description | | -------- | -------- | -------- | | ohos.intl | constructor()8+ | Creates a **RelativeTimeFormat** object. | | ohos.intl | constructor(locale: string \| Array<string>, options?: RelativeTimeFormatInputOptions)8+ | Creates a **RelativeTimeFormat** object and sets the locale and other formatting-related attributes. | @@ -263,22 +263,22 @@ According to grammars in certain languages, the singular or plural form of a nou ### How to Develop -1. Instantiate a **RelativeTimeFormat** object. - Use the default constructor of **RelativeTimeFormat** to obtain the system default locale by accessing the system language and region settings and set it as the locale in the **RelativeTimeFormat** object (**intl** is the name of the imported module). +1. Instantiate a **RelativeTimeFormat** object.
+ Use the default constructor of **RelativeTimeFormat** to obtain the system default locale by accessing the system language and region settings, and set it as the locale in the **RelativeTimeFormat** object. In the code below, **intl** is the name of the imported module. ``` var relativeTimeFormat = new intl.RelativeTimeFormat(); ``` - Alternatively, use your own locale and formatting parameters to create a **RelativeTimeFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [ RelativeTimeFormatInputOptions](../reference/apis/js-apis-intl.md). + Alternatively, use your own locale and formatting parameters to create a **RelativeTimeFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [ RelativeTimeFormatInputOptions](../reference/apis/js-apis-intl.md). ``` var relativeTimeFormat = new intl.RelativeTimeFormat("zh-CN", {numeric: "always", style: "long"}; ``` -2. Format the relative time. - Use the **format** method of **RelativeTimeFormat** to format the relative time. This method receives a numeric value representing the time length and a string-form unit, like **year**, **quarter**, **month**, **week**, **day**, **hour**, **minute**, and **second**. A string is returned as the formatting result. +2. Format the relative time.
+ Use the **format** method of **RelativeTimeFormat** to format the relative time. This method receives a numeric value representing the time length and a string-form unit, like **year**, **quarter**, **month**, **week**, **day**, **hour**, **minute**, and **second**. This method returns a string representing the formatting result. ``` var number = 2; @@ -286,8 +286,8 @@ According to grammars in certain languages, the singular or plural form of a nou var formatResult = relativeTimeFormat.format(number, unit); ``` -3. Obtain each part of the relative time format. - On obtaining each part of the relative time format, customize the relative time formatting result. +3. Obtain each part of the relative time format.
+ Upon obtaining each part of the relative time format, customize the relative time formatting result. ``` var number = 2; @@ -295,8 +295,8 @@ According to grammars in certain languages, the singular or plural form of a nou var formatResult = relativeTimeFormat.formatToParts(number, unit); ``` -4. Access the attributes of the **RelativeTimeFormat** object. - The **resolvedOptions** method of **RelativeTimeFormat** returns an object that contains all related attributes and values of the **RelativeTimeFormat** object. For a full list of attributes, see [ RelativeTimeFormatResolvedOptions](../reference/apis/js-apis-intl.md). +4. Obtain attributes of the **RelativeTimeFormat** object.
+ The **resolvedOptions** method of **RelativeTimeFormat** returns an object that contains all related attributes and values of the **RelativeTimeFormat** object. For a full list of attributes, see [ RelativeTimeFormatResolvedOptions](../reference/apis/js-apis-intl.md). ``` var options = numberFormat.resolvedOptions(); @@ -306,4 +306,4 @@ According to grammars in certain languages, the singular or plural form of a nou The following sample is provided to help you better understand how to develop internationalization capabilities: --[`International`: Internationalization (JS) (API7)](https://gitee.com/openharmony/app_samples/tree/master/UI/International) +-[`International`: Internationalization (JS) (API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/International) diff --git a/en/application-dev/media/video-playback.md b/en/application-dev/media/video-playback.md index feff6a4b8afe805d2e33b2de7778503bfc666686..e6ed5ad6a6c353ace5ae159d861fc9daf1996437 100644 --- a/en/application-dev/media/video-playback.md +++ b/en/application-dev/media/video-playback.md @@ -401,10 +401,6 @@ export class VideoPlayerDemo { } } - sleep(time) { - for(let t = Date.now(); Date.now() - t <= time;); - } - async videoPlayerDemo() { let videoPlayer = undefined; let surfaceID = 'test' // The surfaceID parameter is used for screen display. Its value is obtained through the XComponent API. For details about the document link, see the method of creating the XComponent. @@ -442,27 +438,15 @@ export class VideoPlayerDemo { }, this.failureCallback).catch(this.catchCallback); // Set the loop playback attribute. videoPlayer.loop = true; - // Call the play API to start playback. + // Call the play API to start loop playback. await videoPlayer.play().then(() => { - console.info('play success'); - }, this.failureCallback).catch(this.catchCallback); - // After the progress bar reaches the end, the playback continues for 3 seconds and then starts from the beginning, since loop playback is configured. - await videoPlayer.seek(videoPlayer.duration, media.SeekMode.SEEK_NEXT_SYNC).then((seekDoneTime) => { - console.info('seek duration success'); - }, this.failureCallback).catch(this.catchCallback); - this.sleep(3000); - // Release playback resources. - await videoPlayer.release().then(() => { - console.info('release success'); + console.info('play success, loop value is ' + videoPlayer.loop); }, this.failureCallback).catch(this.catchCallback); - - // Set the related instances to undefined. - videoPlayer = undefined; - surfaceID = undefined; } } ``` ## Samples The following samples are provided to help you better understand how to develop video playback: + - [`VideoPlayer`: Video Playback (eTS, API version 9)](https://gitee.com/openharmony/app_samples/tree/master/media/VideoPlayer) diff --git a/en/application-dev/napi/Readme-EN.md b/en/application-dev/napi/Readme-EN.md new file mode 100644 index 0000000000000000000000000000000000000000..33670e46af96c2bb35b120bd4be23958bce8f84b --- /dev/null +++ b/en/application-dev/napi/Readme-EN.md @@ -0,0 +1,3 @@ +# Native APIs + +- [Using Native APIs in Application Projects](napi-guidelines.md) diff --git a/en/application-dev/notification/common-event.md b/en/application-dev/notification/common-event.md index 99cbc2a32b9cfdc29e56f834e7b834ce3179ef7c..8ea3eaa2d6b2f450f28660ca9f50ad3b99947c8b 100644 --- a/en/application-dev/notification/common-event.md +++ b/en/application-dev/notification/common-event.md @@ -174,4 +174,4 @@ if (this.subscriber != null) { The following sample is provided to help you better understand how to use the common event functionality: -- [`CommonEvent`: eTS Common Event (API 7)](https://gitee.com/openharmony/app_samples/tree/master/Notification/CommonEvent) +- [`CommonEvent`: eTS Common Event (API 8)](https://gitee.com/openharmony/app_samples/tree/master/Notification/CommonEvent) diff --git a/en/application-dev/notification/notification.md b/en/application-dev/notification/notification.md index 8aee267205b79aa897b8e48fbd9606b76a16263f..1a24922a0f7ce6e17e6d65963f13622798348dad 100644 --- a/en/application-dev/notification/notification.md +++ b/en/application-dev/notification/notification.md @@ -262,4 +262,4 @@ Notification.cancel(1, "label", cancelCallback) The following sample is provided to help you better understand how to develop notification functions: -[`Notification`: EtsNotification (API 7)](https://gitee.com/openharmony/app_samples/tree/master/common/Notification) \ No newline at end of file +[`Notification`: EtsNotification (API 8)](https://gitee.com/openharmony/app_samples/tree/master/common/Notification) \ No newline at end of file diff --git a/en/application-dev/quick-start/start-with-ets.md b/en/application-dev/quick-start/start-with-ets.md index 53c1133bfb918ed07e1c6d81f90a2f46a85ca500..66485cd8aaeada2f1896013c7822aacc30b5872d 100644 --- a/en/application-dev/quick-start/start-with-ets.md +++ b/en/application-dev/quick-start/start-with-ets.md @@ -20,17 +20,18 @@ ## eTS Project Files -- **entry** : OpenHarmony project module, which can be built into an ability package ([HAP](../../glossary.md#hap)). - - **src > main > ets** : a collection of eTS source code. - - **src > main > ets > MainAbility** : entry to your application/service. - - **src > main > ets > MainAbility > pages** : pages contained in **MainAbility**. - - **src > main > ets > MainAbility > app.ets** : ability lifecycle file. - - **src > main > resources** : a collection of resource files used by your application/service, such as graphics, multimedia, character strings, and layout files. - - **src > main > config.json** : module configuration file. This file describes the global configuration information of the application/service, the device-specific configuration information, and the configuration information of the HAP file. - - **build-profile.json5** : current module information and build configuration options, including **buildOption target**. - - **hvigorfile.js** : module-level compilation and build task script. You can customize related tasks and code implementation. -- **build-profile.json5** : application-level configuration information, including the signature and product configuration. -- **hvigorfile.js** : application-level compilation and build task script. +- **entry**: OpenHarmony project module, which can be built into an ability package ([HAP](../../glossary.md#hap)). + - **src > main > ets**: a collection of eTS source code. + - **src > main > ets > MainAbility**: entry to your application/service. + - **src > main > ets > MainAbility > pages**: pages contained in **MainAbility**. + - **src > main > ets > MainAbility > pages > index.ets**: the first page in the pages list, that is, the home page of your application. + - **src > main > ets > MainAbility > app.ets**: ability lifecycle file. + - **src > main > resources**: a collection of resource files used by your application/service, such as graphics, multimedia, character strings, and layout files. + - **src > main > config.json**: module configuration file. This file describes the global configuration information of the application/service, the device-specific configuration information, and the configuration information of the HAP file. + - **build-profile.json5**: current module information and build configuration options, including **buildOption target**. + - **hvigorfile.js**: module-level compilation and build task script. You can customize related tasks and code implementation. +- **build-profile.json5**: application-level configuration information, including the signature and product configuration. +- **hvigorfile.js**: application-level compilation and build task script. ## Building the First Page @@ -62,7 +63,7 @@ 2. Add a **<Button>** component. - On the default page, add a **<Button>** component to accept user clicks and implement redirection to another page. The sample code in the **index.ets** file is shown below: + On the default page, add a **<Button>** component to respond to user clicks and implement redirection to another page. The sample code in the **index.ets** file is shown below: ``` @@ -77,7 +78,7 @@ Text(this.message) .fontSize(50) .fontWeight(FontWeight.Bold) - // Add a button to accept user clicks. + // Add a button to respond to user clicks. Button() { Text('Next') .fontSize(30) @@ -174,7 +175,7 @@ You can implement page redirection through the page router, which finds the targ Text(this.message) .fontSize(50) .fontWeight(FontWeight.Bold) - // Add a button to accept user clicks. + // Add a button to respond to user clicks. Button() { Text('Next') .fontSize(30) diff --git a/en/application-dev/quick-start/start-with-js-low-code.md b/en/application-dev/quick-start/start-with-js-low-code.md index a20c01c2f459fc07b799ca847683f99350dd4829..69e650671909a57d56c6486346938a4804de2fdf 100644 --- a/en/application-dev/quick-start/start-with-js-low-code.md +++ b/en/application-dev/quick-start/start-with-js-low-code.md @@ -37,10 +37,11 @@ After the project synchronization is complete, a low-code directory structure is ![en-us_image_0000001223558810](figures/en-us_image_0000001223558810.png) -- **entry > src > main > js > MainAbility > pages > index > index.js** : defines logical relationships, such as data and events, used on low-code pages. For details, see [JavaScript](../ui/js-framework-syntax-js.md). If multiple low-code development pages are created, a page folder and the corresponding **.js** file will be created for each of these pages. +- **entry > src > main > js > MainAbility > pages > index > index.js**: defines logical relationships, such as data and events, used on low-code pages. For details, see [JavaScript](../ui/js-framework-syntax-js.md). If multiple low-code development pages are created, a page folder and the corresponding **.js** file will be created for each of these pages. + > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
To avoid build errors when using the low-code development page, make sure the directory where the corresponding **.js** file is located does not contain **.hml** or **.css** files. For example, in the preceding example, no **.hml** or **.css** file is allowed in **js** > **MainAbility** > **pages** > **index**. > -- **entry > src > main > supervisual > MainAbility > pages > index > index.visual** : stores the data model of the low-code development page. You can double-click the file to open the low-code development page. If multiple low-code development pages are created, a page folder and the corresponding **.visual** file will be created for each of these pages. +- **entry > src > main > supervisual > MainAbility > pages > index > index.visual**: stores the data model of the low-code development page. You can double-click the file to open the low-code development page. If multiple low-code development pages are created, a page folder and the corresponding **.visual** file will be created for each of these pages. ## Building the First Page diff --git a/en/application-dev/quick-start/start-with-js.md b/en/application-dev/quick-start/start-with-js.md index 60131768f2dd3727a4d1467ca92896abb0239752..301da91e43a7f751c4e70135acf5fbce64c3eef8 100644 --- a/en/application-dev/quick-start/start-with-js.md +++ b/en/application-dev/quick-start/start-with-js.md @@ -19,7 +19,7 @@ ## JavaScript Project Files -- **entry** : OpenHarmony project module, which can be built into an ability package ([HAP](../../glossary.md#hap)). +- **entry**: OpenHarmony project module, which can be built into an ability package ([HAP](../../glossary.md#hap)). - **src > main > js**: a collection of JS source code. - **src > main > js > MainAbility**: entry to your application/service. - **src > main > js > MainAbility > i18n**: resources in different languages, for example, UI strings and image paths. @@ -50,7 +50,7 @@ 2. Add a button and bind the **onclick** method to this button. - On the default page, add an **<input>** component of the button type to accept user clicks and implement redirection to another page. The sample code in the **index.hml** file is shown below: + On the default page, add an **<input>** component of the button type to respond to user clicks and implement redirection to another page. The sample code in the **index.hml** file is shown below: ``` diff --git a/en/application-dev/reference/apis/js-apis-data-ability.md b/en/application-dev/reference/apis/js-apis-data-ability.md index 14fba2457383feceeefe0b302b1710e856bc187e..7149bdeeaa292cc1b41a29fc09feef097dcea29f 100644 --- a/en/application-dev/reference/apis/js-apis-data-ability.md +++ b/en/application-dev/reference/apis/js-apis-data-ability.md @@ -1,6 +1,6 @@ # DataAbilityPredicates -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **NOTE**
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -22,6 +22,7 @@ Creates an **RdbPredicates** object based on a **DataAabilityPredicates** object **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Parameters** + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | name | string | Yes| Table name in the RDB store.| diff --git a/en/application-dev/reference/apis/js-apis-data-distributedobject.md b/en/application-dev/reference/apis/js-apis-data-distributedobject.md index 5ac7b6707c3afd30d7ccc6ae966fdf99439bd697..36761408ca6fe04d507711a0664f0903fa48be90 100644 --- a/en/application-dev/reference/apis/js-apis-data-distributedobject.md +++ b/en/application-dev/reference/apis/js-apis-data-distributedobject.md @@ -1,6 +1,6 @@ # Distributed Data Object -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **NOTE**
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -10,8 +10,6 @@ import distributedObject from '@ohos.data.distributedDataObject'; ``` - - ## distributedDataObject.createDistributedObject createDistributedObject(source: object): DistributedObject diff --git a/en/application-dev/reference/apis/js-apis-data-preferences.md b/en/application-dev/reference/apis/js-apis-data-preferences.md index afd07e6d85cd00e521fb230415e9f32cdd5d1fe3..1010a20849fb9da41e445bc5212e88427b3f28c5 100644 --- a/en/application-dev/reference/apis/js-apis-data-preferences.md +++ b/en/application-dev/reference/apis/js-apis-data-preferences.md @@ -3,7 +3,7 @@ Preferences provide capabilities for processing data in the form of key-value (KV) pairs and supports lightweight data persistence, modification, and query. In KV pairs, keys are of the string type, and values can be of the number, string, or Boolean type. -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **NOTE**
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -35,38 +35,20 @@ Reads a **Preferences** persistence file and loads data to the **Preferences** i **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | context | [Context](js-apis-Context.md) | Yes| Context of the application or functionality.| + | context | [Context](js-apis-ability-context.md) | Yes| Context of the application or functionality.| | name | string | Yes| Name of the **Preferences** instance persistence file.| | callback | AsyncCallback<[Preferences](#preferences)> | Yes| Callback used to return the result.| **Example** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) { - if (err) { +```ts +data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) { + if (err) { console.info("Failed to get the preferences") - return; - } - preferences.put('startup', 'auto', function (err) { - if (err) { - console.info("Failed to put the value of startup, err: " + err) - return - } - console.info("Put the value of startup successfully.") - preferences.flush(function (err) { - if (err) { - console.info("Failed to flush data to file, err: " + err) - return - } - console.info("Flushed data to file successfully.") - }) - }) - }) - } - ``` + return; + } + console.info("Got preferences successfully.") +}) +``` ## data_preferences.getPreferences @@ -80,7 +62,7 @@ Reads a **Preferences** persistence file and loads data to the **Preferences** i **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | context | [Context](js-apis-Context.md) | Yes| Context of the application or functionality.| + | context | [Context](js-apis-ability-context.md) | Yes| Context of the application or functionality.| | name | string | Yes| Name of the **Preferences** instance persistence file.| **Return value** @@ -89,32 +71,14 @@ Reads a **Preferences** persistence file and loads data to the **Preferences** i | Promise<[Preferences](#preferences)> | Promise used to return the result.| **Example** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - let promise = data_preferences.getPreferences(this.context, 'mystore') - promise.then((preferences) => { - preferences.put('startup', 'auto', function (err) { - if (err) { - console.info("Failed to put the value of startup, err: " + err) - return - } - console.info("Put the value of startup successfully.") - preferences.flush(function (err) { - if (err) { - console.info("Failed to flush data to file, err: " + err) - return - } - console.info("Flushed data to file successfully.") - }) - }) - }).catch((err) => { +```ts +let promise = data_preferences.getPreferences(this.context, 'mystore') +promise.then((preferences) => { + console.info("Got preferences successfully.") +}).catch((err) => { console.info("Failed to get the preferences") - }) - } - ``` +}) +``` ## data_preferences.deletePreferences @@ -129,25 +93,20 @@ Once a **Preferences** persistence file is deleted, the **Preferences** instance **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | context | [Context](js-apis-Context.md) | Yes| Context of the application or functionality.| + | context | [Context](js-apis-ability-context.md) | Yes| Context of the application or functionality.| | name | string | Yes| Name of the **Preferences** instance persistence file.| | callback | AsyncCallback<void> | Yes| Callback used to return the result.| **Example** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - data_preferences.deletePreferences(this.context, 'mystore', function (err) { - if (err) { +```ts +data_preferences.deletePreferences(this.context, 'mystore', function (err) { + if (err) { console.info("Failed to delete data, err: " + err) - return - } - console.info("Data deleted successfully.") - }) - } - ``` + return + } + console.info("Deleted preferences successfully.") +}) +``` ## data_preferences.deletePreferences @@ -162,7 +121,7 @@ Once a **Preferences** persistence file is deleted, the **Preferences** instance **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | context | [Context](js-apis-Context.md) | Yes| Context of the application or functionality.| + | context | [Context](js-apis-ability-context.md) | Yes| Context of the application or functionality.| | name | string | Yes| Name of the **Preferences** instance persistence file.| **Return value** @@ -171,19 +130,14 @@ Once a **Preferences** persistence file is deleted, the **Preferences** instance | Promise<void> | Promise used to return the result.| **Example** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - let promise = data_preferences.deletePreferences(this.context, 'mystore') - promise.then(() => { - console.info("Data deleted successfully.") - }).catch((err) => { - console.info("Failed to delete data, err: " + err) - }) - } - ``` +```ts +let promise = data_preferences.deletePreferences(this.context, 'mystore') +promise.then(() => { + console.info("Deleted preferences successfully.") +}).catch((err) => { + console.info("Failed to delete preferences, err: " + err) +}) +``` ## data_preferences.removePreferencesFromCache @@ -199,25 +153,20 @@ When a **Preferences** singleton instance is removed, this instance cannot be us **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | context | [Context](js-apis-Context.md) | Yes| Context of the application or functionality.| + | context | [Context](js-apis-ability-context.md) | Yes| Context of the application or functionality.| | name | string | Yes| Name of the **Preferences** instance persistence file.| | callback | AsyncCallback<void> | Yes| Callback used to return the result.| **Example** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - data_preferences.removePreferencesFromCache(this.context, 'mystore', function (err) { - if (err) { - console.info("Failed to remove preferences from cache, err: " + err) - return - } - console.info("Removed preferences from cache successfully.") - }) - } - ``` +```ts +data_preferences.removePreferencesFromCache(this.context, 'mystore', function (err) { + if (err) { + console.info("Failed to remove preferences from cache, err: " + err) + return + } + console.info("Removed preferences from cache successfully.") +}) +``` ## data_preferences.removePreferencesFromCache @@ -230,10 +179,10 @@ When a **Preferences** singleton instance is removed, this instance cannot be us **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -**Parameters** +Parameters | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | context | [Context](js-apis-Context.md) | Yes| Context of the application or functionality.| + | context | [Context](js-apis-ability-context.md) | Yes| Context of the application or functionality.| | name | string | Yes| Name of the **Preferences** instance persistence file.| **Return value** @@ -242,19 +191,14 @@ When a **Preferences** singleton instance is removed, this instance cannot be us | Promise<void> | Promise used to return the result.| **Example** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - let promise = data_preferences.removePreferencesFromCache(this.context, 'mystore') - promise.then(() => { - console.info("Removed preferences from cache successfully.") - }).catch((err) => { - console.info("Failed to remove preferences from cache, err: " + err) - }) - } - ``` +```ts +let promise = data_preferences.removePreferencesFromCache(this.context, 'mystore') +promise.then(() => { + console.info("Removed preferences from cache successfully.") +}).catch((err) => { + console.info("Failed to remove preferences from cache, err: " + err) +}) +``` ## Preferences @@ -278,26 +222,15 @@ Obtains the value of a key. If the value is null or a non-default value, the def | callback | AsyncCallback<ValueType> | Yes| Callback used to return the result.| **Example** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) { - if (err) { - console.info("Failed to get the preferences, err: " + err) - return - } - preferences.get('startup', 'default', function(err, value) { - if (err) { +```ts + preferences.get('startup', 'default', function(err, value) { + if (err) { console.info("Failed to get the value of startup, err: " + err) - return - } + return + } console.info("The value of startup is " + value) - }) - }) - } - ``` +}) +``` ### get @@ -320,24 +253,14 @@ Obtains the value of a key. If the value is null or a non-default value, the def | Promise<ValueType> | Promise used to return the result.| **Example** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - let promise = data_preferences.getPreferences(this.context, 'mystore') - promise.then((preferences) => { - let promiseGet = preferences.get('startup', 'default') - promiseGet.then((value) => { - console.info("The value of startup is " + value) - }).catch((err) => { +```ts +let promise = preferences.get('startup', 'default') +promise.then((value) => { + console.info("The value of startup is " + value) +}).catch((err) => { console.info("Failed to get the value of startup, err: " + err) - }) - }).catch((err) => { - console.info("Failed to get the preferences, err: " + err) - }) - } - ``` +}) +``` ### put @@ -356,26 +279,15 @@ Puts a new value to this **Preferences** instance and its persistence file. This | callback | AsyncCallback<void> | Yes| Callback used to return the result.| **Example** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) { - if (err) { - console.info("Failed to get the preferences, err: " + err) - return - } - preferences.put('startup', 'auto', function (err) { - if (err) { +```ts +preferences.put('startup', 'auto', function (err) { + if (err) { console.info("Failed to put the value of startup, err: " + err) - return - } - console.info("Put the value of startup successfully.") - }) - }) - } - ``` + return + } + console.info("Put the value of startup successfully.") +}) +``` ### put @@ -398,24 +310,14 @@ Puts a new value to this **Preferences** instance and its persistence file. This | Promise<void> | Promise used to return the result.| **Example** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - let promise = data_preferences.getPreferences(this.context, 'mystore') - promise.then((preferences) => { - let promisePut = preferences.put('startup', 'auto') - promisePut.then(() => { - console.info("Put the value of startup successfully.") - }).catch((err) => { +```ts +let promise = preferences.put('startup', 'auto') +promise.then(() => { + console.info("Put the value of startup successfully.") +}).catch((err) => { console.info("Failed to put the value of startup, err: " + err) - }) - }).catch((err) => { - console.info("Failed to get the preferences, err: " + err) - }) - } - ``` +}) +``` ### has @@ -438,30 +340,19 @@ Checks whether this **Preferences** instance contains data with a given key. Thi | boolean | Returns **true** if the **Preferences** instance contains data with the specified key; returns **false** otherwise.| **Example** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) { - if (err) { - console.info("Failed to get the preferences, err: " + err) - return - } - preferences.has('startup', function (err, isExist) { - if (err) { - console.info("Failed to check the key of startup, err: " + err) - return - } - if (isExist) { - console.info("The key of startup is contained.") - } else { - console.info("The key of startup is not contained.") - } - }) - }) - } - ``` +```ts +preferences.has('startup', function (err, isExist) { + if (err) { + console.info("Failed to check the key of startup, err: " + err) + return + } + if (isExist) { + console.info("The key of startup is contained.") + } else { + console.info("The key of startup is not contained.") + } +}) +``` ### has @@ -483,28 +374,18 @@ Checks whether this **Preferences** instance contains data with a given key. Thi | Promise<boolean> | Promise used to return the result.| **Example** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - let promise = data_preferences.getPreferences(this.context, 'mystore') - promise.then((preferences) => { - let promiseHas = preferences.has('startup') - promiseHas.then((isExist) => { - if (isExist) { - console.info("The key of startup is contained.") - } else { - console.info("The key of startup is not contained.") - } - }).catch((err) => { +```ts +let promise = preferences.has('startup') +promise.then((isExist) => { + if (isExist) { + console.info("The key of startup is contained.") + } else { + console.info("The key of startup is not contained.") + } +}).catch((err) => { console.info("Check the key of startup failed, err: " + err) - }) - }).catch((err) => { - console.info("Failed to get the preferences, err: " + err) - }) - } - ``` +}) +``` ### delete @@ -522,26 +403,15 @@ Deletes a KV pair of the specified key from this **Preferences** instance. This | callback | AsyncCallback<void> | Yes| Callback used to return the result.| **Example** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) { - if (err) { - console.info("Failed to get the preferences, err: " + err) - return - } - preferences.delete('startup', function (err) { - if (err) { - console.info("Failed to delete startup key, err: " + err) - return - } - console.info("Deleted startup key successfully.") - }) - }) - } - ``` +```ts +preferences.delete('startup', function (err) { + if (err) { + console.info("Failed to delete startup key, err: " + err) + return + } + console.info("Deleted startup key successfully.") +}) +``` ### delete @@ -563,24 +433,14 @@ Deletes a KV pair of the specified key from this **Preferences** instance. This | Promise<void> | Promise used to return the result.| **Example** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - let promise = data_preferences.getPreferences(this.context, 'mystore') - promise.then((preferences) => { - let promiseDelete = preferences.delete('startup') - promiseDelete.then(() => { - console.info("Deleted startup key successfully.") - }).catch((err) => { - console.info("Failed to delete startup key, err: " + err) - }) - }).catch((err) => { - console.info("Failed to get the preferences, err: " + err) - }) - } - ``` +```ts +let promise = preferences.delete('startup') +promise.then(() => { + console.info("Deleted startup key successfully.") +}).catch((err) => { + console.info("Failed to delete startup key, err: " + err) +}) +``` ### flush @@ -597,26 +457,15 @@ Saves the modification to this **Preferences** instance and synchronizes the mod | callback | AsyncCallback<void> | Yes| Callback used to return the result.| **Example** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) { - if (err) { - console.info("Failed to get the preferences, err: " + err) - return - } - preferences.flush(function (err) { - if (err) { - console.info("Failed to flush data to file, err: " + err) - return - } - console.info("Flushed data to file successfully.") - }) - }) - } - ``` +```ts +preferences.flush(function (err) { + if (err) { + console.info("Failed to flush data to file, err: " + err) + return + } + console.info("Flushed data to file successfully.") +}) +``` ### flush @@ -633,24 +482,14 @@ Saves the modification to this **Preferences** instance and synchronizes the mod | Promise<void> | Promise used to return the result.| **Example** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - let promise = data_preferences.getPreferences(this.context, 'mystore') - promise.then((preferences) => { - let promiseFlush = preferences.flush() - promiseFlush.then(() => { - console.info("Flushed data to file successfully.") - }).catch((err) => { - console.info("Failed to flush data to file, err: " + err) - }) - }).catch((err) => { - console.info("Failed to get the preferences, err: " + err) - }) - } - ``` +```ts +let promise = preferences.flush() +promise.then(() => { + console.info("Flushed data to file successfully.") +}).catch((err) => { + console.info("Failed to flush data to file, err: " + err) +}) +``` ### clear @@ -661,32 +500,21 @@ Clears data of this **Preferences** instance. This API uses an asynchronous call **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -**Parameters** +Parameters | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | callback | AsyncCallback<void> | Yes| Callback used to return the result.| **Example** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) { - if (err) { - console.info("Failed to get the preferences, err: " + err) - return - } - preferences.clear(function (err) { - if (err) { - console.info("Failed to clear data, err: " + err) - return - } - console.info("Cleared to file successfully.") - }) - }) - } - ``` +```ts +preferences.clear(function (err) { + if (err) { + console.info("Failed to clear data, err: " + err) + return + } + console.info("Cleared to file successfully.") +}) +``` ### clear @@ -703,24 +531,14 @@ Clears data of this **Preferences** instance. This API uses a promise to return | Promise<void> | Promise used to return the result.| **Example** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - let promise = data_preferences.getPreferences(this.context, 'mystore') - promise.then((preferences) => { - let promiseClear = preferences.clear() - promiseClear.then(() => { - console.info("Cleared to file successfully.") - }).catch((err) => { - console.info("Failed to clear data, err: " + err) - }) - }).catch((err) => { - console.info("Failed to get the preferences, err: " + err) - }) - } - ``` +```ts +let promise = preferences.clear() +promise.then(() => { + console.info("Cleared to file successfully.") +}).catch((err) => { + console.info("Failed to clear data, err: " + err) +}) +``` ### on('change') @@ -738,37 +556,30 @@ Subscribes to data changes. When the value of the subscribed key changes, a call | callback | Callback<{ key : string }> | Callback used to return data changes.| **Example** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - - var observer = function (key) { - console.info("The key of " + key + " changed.") - } - data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) { - if (err) { - console.info("Failed to get the preferences, err: " + err) - return - } - preferences.on('change', observer) - preferences.put('startup', 'auto', function (err) { - if (err) { - console.info("Failed to put the value of startup, err: " + err) - return - } - console.info("Put the value of startup successfully.") - preferences.flush(function (err) { - if (err) { - console.info("Failed to flush data to file, err: " + err) - return - } - console.info("Flushed data to file successfully.") // The observer will be called. - }) - }) - }) - } - ``` +```ts +var observer = function (key) { + console.info("The key of " + key + " changed.") +} + +... + +preferences.on('change', observer) +preferences.put('startup', 'auto', function (err) { + if (err) { + console.info("Failed to put the value of startup, err: " + err) + return + } + console.info("Put the value of startup successfully.") + + preferences.flush(function (err) { + if (err) { + console.info("Failed to flush data to file, err: " + err) + return + } + console.info("Flushed data to file successfully.") // The observer will be called. + }) +}) +``` ### off('change') @@ -786,37 +597,31 @@ Unsubscribes from data changes. | callback | Callback<{ key : string }> | Callback used to return data changes.| **Example** - ```ts - import Ability from '@ohos.application.Ability' - import data_preferences from '@ohos.data.preferences' - export default class MainAbility extends Ability { - var observer = function (key) { - console.info("The key of " + key + " changed.") - } - data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) { - if (err) { - console.info("Failed to get the preferences, err: " + err) - return - } - preferences.on('change', observer) - preferences.put('startup', 'auto', function (err) { - if (err) { - console.info("Failed to put the value of startup, err: " + err) - return - } - console.info("Put the value of startup successfully.") - preferences.flush(function (err) { - if (err) { - console.info("Failed to flush data to file, err: " + err) - return - } - console.info("Flushed to file successfully.") // observer will be called. - preferences.off('change', observer) - }) - }) - }) - } - ``` +```ts +var observer = function (key) { + console.info("The key of " + key + " changed.") +} + +... + +preferences.on('change', observer) +preferences.put('startup', 'auto', function (err) { + if (err) { + console.info("Failed to put the value of startup, err: " + err) + return + } + console.info("Put the value of startup successfully.") + + preferences.flush(function (err) { + if (err) { + console.info("Failed to flush data to file, err: " + err) + return + } + console.info("Flushed data to file successfully.") // The observer will be called. + preferences.off('change', observer) + }) +}) +``` ## ValueType 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 73a87a94f29df9c506a2ea1b41dd7e5f69610e7b..f1211dc922a699081aeab7a5b145771923d8f7fe 100644 --- a/en/application-dev/reference/apis/js-apis-data-rdb.md +++ b/en/application-dev/reference/apis/js-apis-data-rdb.md @@ -29,11 +29,12 @@ Obtains a relational database (RDB) store. This API uses an asynchronous callbac ```js const STORE_CONFIG = { name: "RdbTest.db"} -const SQL_CREATE_TABLE = "CREATE TABLE IF NOT EXISTS EMPLOYEE (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, AGE INTEGER, SALARY REAL, CODES BLOB)" data_rdb.getRdbStore(STORE_CONFIG, 1, function (err, rdbStore) { - rdbStore.executeSql(SQL_CREATE_TABLE, null, function() { - console.info('create table done.') - }) + if (err) { + console.info("Failed to get RdbStore, err: " + err) + return + } + console.log("Got RdbStore successfully.") }) ``` ## data_rdb.getRdbStore @@ -61,17 +62,11 @@ Obtains an RDB store. This API uses a promise to return the result. You can set ```js const STORE_CONFIG = { name: "RdbTest.db" } -const SQL_CREATE_TABLE = "CREATE TABLE IF NOT EXISTS EMPLOYEE (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, AGE INTEGER, SALARY REAL, CODES BLOB)" -let promisegetRdb = data_rdb.getRdbStore(STORE_CONFIG, 1); -promisegetRdb.then(async (rdbStore) => { - let promiseExecSql = rdbStore.executeSql(SQL_CREATE_TABLE, null) - promiseExecSql.then(() => { - console.info('executeSql creat done.') - }).catch((err) => { - console.log("executeSql creat err.") - }) +let promise = data_rdb.getRdbStore(STORE_CONFIG, 1); +promise.then(async (rdbStore) => { + console.log("Got RdbStore successfully.") }).catch((err) => { - console.log("getRdbStore err.") + console.log("Failed to get RdbStore, err: " + err) }) ``` @@ -97,11 +92,12 @@ Obtains a relational database (RDB) store. This API uses an asynchronous callbac ```js const STORE_CONFIG = { name: "RdbTest.db"} -const SQL_CREATE_TABLE = "CREATE TABLE IF NOT EXISTS EMPLOYEE (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, AGE INTEGER, SALARY REAL, CODES BLOB)" data_rdb.getRdbStore(this.context, STORE_CONFIG, 1, function (err, rdbStore) { - rdbStore.executeSql(SQL_CREATE_TABLE, null, function() { - console.info('create table done.') - }) + if (err) { + console.info("Failed to get RdbStore, err: " + err) + return + } + console.log("Got RdbStore successfully.") }) ``` @@ -131,17 +127,11 @@ Obtains an RDB store. This API uses a promise to return the result. You can set ```js const STORE_CONFIG = { name: "RdbTest.db" } -const SQL_CREATE_TABLE = "CREATE TABLE IF NOT EXISTS EMPLOYEE (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, AGE INTEGER, SALARY REAL, CODES BLOB)" -let promisegetRdb = data_rdb.getRdbStore(this.context, STORE_CONFIG, 1); -promisegetRdb.then(async (rdbStore) => { - let promiseExecSql = rdbStore.executeSql(SQL_CREATE_TABLE, null) - promiseExecSql.then(() => { - console.info('executeSql creat done.') - }).catch((err) => { - console.log("executeSql creat err.") - }) +let promise = data_rdb.getRdbStore(this.context, STORE_CONFIG, 1); +promise.then(async (rdbStore) => { + console.log("Got RdbStore successfully.") }).catch((err) => { - console.log("getRdbStore err.") + console.log("Failed to get RdbStore, err: " + err) }) ``` @@ -160,11 +150,15 @@ Deletes an RDB store. This API uses a callback to return the result. | callback | AsyncCallback<void> | Yes| Callback invoked to return the result.| **Example** - ```js - data_rdb.deleteRdbStore("RdbTest.db", function (err, rdbStore) { - console.info('delete store done.') - }) - ``` +```js +data_rdb.deleteRdbStore("RdbTest.db", function (err, rdbStore) { + if (err) { + console.info("Failed to delete RdbStore, err: " + err) + return + } + console.log("Deleted RdbStore successfully.") +}) +``` ## data_rdb.deleteRdbStore deleteRdbStore(name: string): Promise<void> @@ -184,14 +178,14 @@ Deletes an RDB store. This API uses a promise to return the result. | Promise<void> | Promise used to return the result.| **Example** - ```js - let promisedeleteRdb = data_rdb.deleteRdbStore("RdbTest.db") - promisedeleteRdb.then(()=>{ - console.info('delete store done.') - }).catch((err) => { - console.log("deleteRdbStore err.") - }) - ``` +```js +let promise = data_rdb.deleteRdbStore("RdbTest.db") +promise.then(()=>{ + console.log("Deleted RdbStore successfully.") +}).catch((err) => { + console.info("Failed to delete RdbStore, err: " + err) +}) +``` ## data_rdb.deleteRdbStore8+ @@ -209,11 +203,15 @@ Deletes an RDB store. This API uses a callback to return the result. | callback | AsyncCallback<void> | Yes| Callback invoked to return the result.| **Example** - ```js - data_rdb.deleteRdbStore(this.context, "RdbTest.db", function (err, rdbStore) { - console.info('delete store done.') - }) - ``` +```js +data_rdb.deleteRdbStore(this.context, "RdbTest.db", function (err, rdbStore) { + if (err) { + console.info("Failed to delete RdbStore, err: " + err) + return + } + console.log("Deleted RdbStore successfully.") +}) +``` ## data_rdb.deleteRdbStore8+ @@ -235,14 +233,14 @@ Deletes an RDB store. This API uses a promise to return the result. | Promise<void> | Promise used to return the result.| **Example** - ```js - let promisedeleteRdb = data_rdb.deleteRdbStore("RdbTest.db") - promisedeleteRdb.then(()=>{ - console.info('delete store done.') - }).catch((err) => { - console.log("deleteRdbStore err.") - }) - ``` +```js +let promise = data_rdb.deleteRdbStore("RdbTest.db") +promise.then(()=>{ + console.log("Deleted RdbStore successfully.") +}).catch((err) => { + console.info("Failed to delete RdbStore, err: " + err) +}) +``` ## RdbPredicates @@ -265,9 +263,9 @@ A constructor used to create an **RdbPredicates** object. | name | string | Yes| Database table name.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +``` ### inDevices8+ @@ -289,10 +287,10 @@ Specifies a remote device on the network during distributed database synchroniza | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.inDevices(['12345678abcde']) - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.inDevices(['12345678abcde']) +``` ### inAllDevices8+ @@ -309,10 +307,10 @@ Connects to all remote devices on the network during distributed database synchr | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.inAllDevices() - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.inAllDevices() +``` ### equalTo @@ -335,10 +333,10 @@ Sets the **RdbPredicates** to match the field with data type **ValueType** and v | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.equalTo("NAME", "lisi") - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.equalTo("NAME", "lisi") +``` ### notEqualTo @@ -362,10 +360,10 @@ Sets the **RdbPredicates** to match the field with data type **ValueType** and v | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.notEqualTo("NAME", "lisi") - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.notEqualTo("NAME", "lisi") +``` ### beginWrap @@ -383,15 +381,15 @@ Adds a left parenthesis to the **RdbPredicates**. | [RdbPredicates](#rdbpredicates) | **RdbPredicates** with a left parenthesis.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.equalTo("NAME", "lisi") - .beginWrap() - .equalTo("AGE", 18) - .or() - .equalTo("SALARY", 200.5) - .endWrap() - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.equalTo("NAME", "lisi") + .beginWrap() + .equalTo("AGE", 18) + .or() + .equalTo("SALARY", 200.5) + .endWrap() +``` ### endWrap @@ -409,15 +407,15 @@ Adds a right parenthesis to the **RdbPredicates**. | [RdbPredicates](#rdbpredicates) | **RdbPredicates** with a right parenthesis.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.equalTo("NAME", "lisi") - .beginWrap() - .equalTo("AGE", 18) - .or() - .equalTo("SALARY", 200.5) - .endWrap() - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.equalTo("NAME", "lisi") + .beginWrap() + .equalTo("AGE", 18) + .or() + .equalTo("SALARY", 200.5) + .endWrap() +``` ### or @@ -435,12 +433,12 @@ Adds the OR condition to the **RdbPredicates**. | [RdbPredicates](#rdbpredicates) | **RdbPredicates** with the OR condition.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.equalTo("NAME", "Lisa") - .or() - .equalTo("NAME", "Rose") - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.equalTo("NAME", "Lisa") + .or() + .equalTo("NAME", "Rose") +``` ### and @@ -458,12 +456,12 @@ Adds the AND condition to the **RdbPredicates**. | [RdbPredicates](#rdbpredicates) | **RdbPredicates** with the AND condition.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.equalTo("NAME", "Lisa") - .and() - .equalTo("SALARY", 200.5) - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.equalTo("NAME", "Lisa") + .and() + .equalTo("SALARY", 200.5) +``` ### contains @@ -486,10 +484,10 @@ Sets the **RdbPredicates** to match a string containing the specified value. | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.contains("NAME", "os") - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.contains("NAME", "os") +``` ### beginsWith @@ -513,10 +511,10 @@ Sets the **RdbPredicates** to match a string that starts with the specified valu | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.beginsWith("NAME", "os") - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.beginsWith("NAME", "os") +``` ### endsWith @@ -540,10 +538,10 @@ Sets the **RdbPredicates** to match a string that ends with the specified value. | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.endsWith("NAME", "se") - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.endsWith("NAME", "se") +``` ### isNull @@ -566,10 +564,10 @@ Sets the **RdbPredicates** to match the field whose value is null. | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| - Example - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.isNull("NAME") - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.isNull("NAME") +``` ### isNotNull @@ -592,10 +590,10 @@ Sets the **RdbPredicates** to match the field whose value is not null. | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.isNotNull("NAME") - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.isNotNull("NAME") +``` ### like @@ -619,10 +617,10 @@ Sets the **RdbPredicates** to match a string that is similar to the specified va | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.like("NAME", "%os%") - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.like("NAME", "%os%") +``` ### glob @@ -646,10 +644,10 @@ Sets the **RdbPredicates** to match the specified string. | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.glob("NAME", "?h*g") - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.glob("NAME", "?h*g") +``` ### between @@ -674,10 +672,10 @@ Sets the **RdbPredicates** to match the field with data type **ValueType** and v | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.between("AGE", 10, 50) - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.between("AGE", 10, 50) +``` ### notBetween @@ -702,10 +700,10 @@ Sets the **RdbPredicates** to match the field with data type **ValueType** and v | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.notBetween("AGE", 10, 50) - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.notBetween("AGE", 10, 50) +``` ### greaterThan @@ -728,10 +726,10 @@ Sets the **RdbPredicates** to match the field with data type **ValueType** and v | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.greaterThan("AGE", 18) - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.greaterThan("AGE", 18) +``` ### lessThan @@ -755,10 +753,10 @@ Sets the **RdbPredicates** to match the field with data type **ValueType** and v | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.lessThan("AGE", 20) - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.lessThan("AGE", 20) +``` ### greaterThanOrEqualTo @@ -783,10 +781,10 @@ Sets the **RdbPredicates** to match the field with data type **ValueType** and v | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.greaterThanOrEqualTo("AGE", 18) - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.greaterThanOrEqualTo("AGE", 18) +``` ### lessThanOrEqualTo @@ -811,10 +809,10 @@ Sets the **RdbPredicates** to match the field with data type **ValueType** and v | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.lessThanOrEqualTo("AGE", 20) - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.lessThanOrEqualTo("AGE", 20) +``` ### orderByAsc @@ -838,10 +836,10 @@ Sets the **RdbPredicates** to match the column with values sorted in ascending o | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.orderByAsc("NAME") - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.orderByAsc("NAME") +``` ### orderByDesc @@ -865,10 +863,10 @@ Sets the **RdbPredicates** to match the column with values sorted in descending | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.orderByDesc("AGE") - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.orderByDesc("AGE") +``` ### distinct @@ -886,17 +884,17 @@ Sets the **RdbPredicates** to filter out duplicate records. | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that can filter out duplicate records.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.equalTo("NAME", "Rose").distinct("NAME") - let promisequery = rdbStore.query(predicates, ["NAME"]) - promisequery.then((resultSet) => { - console.log("resultSet column names:" + resultSet.columnNames) - console.log("resultSet column count:" + resultSet.columnCount) - }).catch((err) => { - console.log("query err.") - }) - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.equalTo("NAME", "Rose").distinct("NAME") +let promise = rdbStore.query(predicates, ["NAME"]) +promise.then((resultSet) => { + console.log("resultSet column names:" + resultSet.columnNames) + console.log("resultSet column count:" + resultSet.columnCount) +}).catch((err) => { + console.log("query err.") +}) +``` ### limitAs @@ -919,10 +917,10 @@ Sets the **RdbPredicates** to specify the maximum number of records. | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that specifies the maximum number of records.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.equalTo("NAME", "Rose").limitAs(3) - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.equalTo("NAME", "Rose").limitAs(3) +``` ### offsetAs @@ -945,10 +943,10 @@ Sets the **RdbPredicates** to specify the start position of the returned result. | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that specifies the start position of the returned result.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.equalTo("NAME", "Rose").offsetAs(3) - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.equalTo("NAME", "Rose").offsetAs(3) +``` ### groupBy @@ -971,10 +969,10 @@ Sets the **RdbPredicates** to group rows that have the same value into summary r | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that groups rows with the same value.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.groupBy(["AGE", "NAME"]) - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.groupBy(["AGE", "NAME"]) +``` ### indexedBy @@ -997,10 +995,10 @@ Sets the **RdbPredicates** object to specify the index column. | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that specifies the index column.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.indexedBy("SALARY_INDEX") - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.indexedBy("SALARY_INDEX") +``` ### in @@ -1025,10 +1023,10 @@ Sets the **RdbPredicates** to match the field with data type **Array<ValueTy | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.in("AGE", [18, 20]) - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.in("AGE", [18, 20]) +``` ### notIn @@ -1053,10 +1051,10 @@ Sets the **RdbPredicates** to match the field with data type **Array<ValueTy | [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that matches the specified field.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.notIn("NAME", ["Lisa", "Rose"]) - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.notIn("NAME", ["Lisa", "Rose"]) +``` ## RdbStore @@ -1080,17 +1078,21 @@ Inserts a row of data into a table. This API uses a callback to return the resul | callback | AsyncCallback<number> | Yes| Callback invoked to return the result. If the operation is successful, the row ID will be returned. Otherwise, **-1** will be returned.| **Example** - ```js - const valueBucket = { - "NAME": "Lisa", - "AGE": 18, - "SALARY": 100.5, - "CODES": new Uint8Array([1, 2, 3, 4, 5]), - } - rdbStore.insert("EMPLOYEE", valueBucket, function (err, ret) { - console.log("insert first done: " + ret) - }) - ``` +```js +const valueBucket = { + "NAME": "Lisa", + "AGE": 18, + "SALARY": 100.5, + "CODES": new Uint8Array([1, 2, 3, 4, 5]), +} +rdbStore.insert("EMPLOYEE", valueBucket, function (err, ret) { + if (err) { + console.info("Failed to insert data, err: " + err) + return + } + console.log("Insert first done: " + ret) +}) +``` ### insert @@ -1113,20 +1115,20 @@ Inserts a row of data into a table. This API uses a promise to return the result | Promise<number> | Promise used to return the result. If the operation is successful, the row ID will be returned. Otherwise, **-1** will be returned.| **Example** - ```js - const valueBucket = { - "NAME": "Lisa", - "AGE": 18, - "SALARY": 100.5, - "CODES": new Uint8Array([1, 2, 3, 4, 5]), - } - let promiseinsert = rdbStore.insert("EMPLOYEE", valueBucket) - promiseinsert.then(async (ret) => { - console.log("insert first done: " + ret) - }).catch((err) => { - console.log("insert err.") - }) - ``` +```js +const valueBucket = { + "NAME": "Lisa", + "AGE": 18, + "SALARY": 100.5, + "CODES": new Uint8Array([1, 2, 3, 4, 5]), +} +let promise = rdbStore.insert("EMPLOYEE", valueBucket) +promise.then(async (ret) => { + console.log("Insert first done: " + ret) +}).catch((err) => { + console.log("Failed to insert data, err: " + err) +}) +``` ### update @@ -1145,18 +1147,23 @@ Updates data in the database based on the specified RdbPredicates object. This A | callback | AsyncCallback<number> | Yes| Callback used to return the number of rows updated.| **Example** - ```js - const valueBucket = { - "NAME": "Rose", - "AGE": 22, - "SALARY": 200.5, - "CODES": new Uint8Array([1, 2, 3, 4, 5]), - } - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.equalTo("NAME", "Lisa") - rdbStore.update(valueBucket, predicates, function (err, ret) { - console.log("updated row count: " + ret)}) - ``` +```js +const valueBucket = { + "NAME": "Rose", + "AGE": 22, + "SALARY": 200.5, + "CODES": new Uint8Array([1, 2, 3, 4, 5]), +} +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.equalTo("NAME", "Lisa") +rdbStore.update(valueBucket, predicates, function (err, ret) { + if (err) { + console.info("Failed to update data, err: " + err) + return + } + console.log("Updated row count: " + ret) +}) +``` ### update @@ -1179,22 +1186,22 @@ Updates data in the database based on the specified RdbPredicates object. This A | Promise<number> | Promise used to return the number of rows updated.| **Example** - ```js - const valueBucket = { - "NAME": "Rose", - "AGE": 22, - "SALARY": 200.5, - "CODES": new Uint8Array([1, 2, 3, 4, 5]), - } - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.equalTo("NAME", "Lisa") - let promiseupdate = rdbStore.update(valueBucket, predicates) - promiseupdate.then(async (ret) => { - console.log("updated row count: " + ret) - }).catch((err) => { - console.log("update err.") - }) - ``` +```js +const valueBucket = { + "NAME": "Rose", + "AGE": 22, + "SALARY": 200.5, + "CODES": new Uint8Array([1, 2, 3, 4, 5]), +} +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.equalTo("NAME", "Lisa") +let promise = rdbStore.update(valueBucket, predicates) +promise.then(async (ret) => { + console.log("Updated row count: " + ret) +}).catch((err) => { + console.info("Failed to update data, err: " + err) +}) +``` ### delete @@ -1213,13 +1220,17 @@ Deletes data from the database based on the specified RdbPredicates object. This | callback | AsyncCallback<number> | Yes| Callback invoked to return the number of rows updated.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.equalTo("NAME", "Lisa") - rdbStore.delete(predicates, function (err, rows) { - console.log("delete rows: " + rows) - }) - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.equalTo("NAME", "Lisa") +rdbStore.delete(predicates, function (err, rows) { + if (err) { + console.info("Failed to delete data, err: " + err) + return + } + console.log("Delete rows: " + rows) +}) +``` ### delete @@ -1241,16 +1252,16 @@ Deletes data from the database based on the specified RdbPredicates object. This | Promise<number> | Promise used to return the number of rows updated.| **Example** - ```js - let predicatesdelete = new data_rdb.RdbPredicates("EMPLOYEE") - predicatesdelete.equalTo("NAME", "Lisa") - let promisedelete = rdbStore.delete(predicates) - promisedelete.then((rows) => { - console.log("delete rows: " + rows) - }).catch((err) => { - console.log("delete err.") - }) - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.equalTo("NAME", "Lisa") +let promise = rdbStore.delete(predicates) +promise.then((rows) => { + console.log("Delete rows: " + rows) +}).catch((err) => { + console.info("Failed to delete data, err: " + err) +}) +``` ### query @@ -1269,14 +1280,18 @@ Queries data in the database based on specified conditions. This API uses a call | callback | AsyncCallback<[ResultSet](js-apis-data-resultset.md)> | Yes| Callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.| **Example** - ```js - let predicates = new data_rdb.RdbPredicates("EMPLOYEE") - predicates.equalTo("NAME", "Rose") - rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"], function (err, resultSet) { - console.log("resultSet column names:" + resultSet.columnNames) - console.log("resultSet column count:" + resultSet.columnCount) - }) - ``` +```js +let predicates = new data_rdb.RdbPredicates("EMPLOYEE") +predicates.equalTo("NAME", "Rose") +rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"], function (err, resultSet) { + if (err) { + console.info("Query failed, err: " + err) + return + } + console.log("resultSet column names:" + resultSet.columnNames) + console.log("resultSet column count:" + resultSet.columnCount) +}) +``` ### query @@ -1302,12 +1317,12 @@ Queries data in the database based on specified conditions. This API uses a prom ```js let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.equalTo("NAME", "Rose") - let promisequery = rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]) - promisequery.then((resultSet) => { + let promise = rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]) + promise.then((resultSet) => { console.log("resultSet column names:" + resultSet.columnNames) console.log("resultSet column count:" + resultSet.columnCount) }).catch((err) => { - console.log("query err.") + console.info("Query failed, err: " + err) }) ``` @@ -1328,12 +1343,16 @@ Queries data in the RDB store using the specified SQL statement. This API uses a | callback | AsyncCallback<[ResultSet](js-apis-data-resultset.md)> | Yes| Callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.| **Example** - ```js - rdbStore.querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = ?", ['sanguo'], function (err, resultSet) { - console.log("resultSet column names:" + resultSet.columnNames) - console.log("resultSet column count:" + resultSet.columnCount) - }) - ``` +```js +rdbStore.querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = ?", ['sanguo'], function (err, resultSet) { + if (err) { + console.info("Query failed, err: " + err) + return + } + console.log("resultSet column names:" + resultSet.columnNames) + console.log("resultSet column count:" + resultSet.columnCount) +}) +``` ### querySql8+ @@ -1356,15 +1375,15 @@ Queries data in the RDB store using the specified SQL statement. This API uses a | Promise<[ResultSet](../apis/js-apis-data-resultset.md)> | Promise used to return the result. If the operation is successful, a **ResultSet** object will be returned.| **Example** - ```js - let promisequerySql = rdbStore.querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = ?", ['sanguo']) - promisequerySql.then((resultSet) => { - console.log("resultSet column names:" + resultSet.columnNames) - console.log("resultSet column count:" + resultSet.columnCount) - }).catch((err) => { - console.log("querySql err.") - }) - ``` +```js +let promise = rdbStore.querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = ?", ['sanguo']) +promise.then((resultSet) => { + console.log("resultSet column names:" + resultSet.columnNames) + console.log("resultSet column count:" + resultSet.columnCount) +}).catch((err) => { + console.info("Query failed, err: " + err) +}) +``` ### executeSql @@ -1383,11 +1402,16 @@ Runs the SQL statement that contains the specified parameters but does not retur | callback | AsyncCallback<void> | Yes| Callback invoked to return the result.| **Example** - ```js - rdbStore.executeSql("DELETE FROM EMPLOYEE", null, function () { - console.info('delete done.') - }) - ``` +```js +const SQL_CREATE_TABLE = "CREATE TABLE IF NOT EXISTS EMPLOYEE (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, AGE INTEGER, SALARY REAL, CODES BLOB)" +rdbStore.executeSql(SQL_CREATE_TABLE, null, function(err) { + if (err) { + console.info("executeSql failed, err: " + err) + return + } + console.info('create table done.') +}) +``` ### executeSql @@ -1410,14 +1434,15 @@ Runs the SQL statement that contains the specified parameters but does not retur | Promise<void> | Promise used to return the result.| **Example** - ```js - let promiseexecuteSql = rdbStore.executeSql("DELETE FROM EMPLOYEE") - promiseexecuteSql.then(() => { - console.info('delete done.') - }).catch((err) => { - console.log("executeSql err.") - }) - ``` +```js +const SQL_CREATE_TABLE = "CREATE TABLE IF NOT EXISTS EMPLOYEE (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, AGE INTEGER, SALARY REAL, CODES BLOB)" +let promise = rdbStore.executeSql(SQL_CREATE_TABLE) +promise.then(() => { + console.info('create table done.') +}).catch((err) => { + console.info("ExecuteSql failed, err: " + err) +}) +``` ### beginTransaction8+ @@ -1429,17 +1454,21 @@ Starts the transaction before executing an SQL statement. **Example** ```js - rdbStore.beginTransaction() - const valueBucket = { - "name": "lisi", - "age": 18, - "salary": 100.5, - "blobType": new Uint8Array([1, 2, 3]), - } - rdbStore.insert("test", valueBucket, function (err, ret) { - console.log("insert done: " + ret) - }) - rdbStore.commit() +rdbStore.beginTransaction() +const valueBucket = { + "name": "lisi", + "age": 18, + "salary": 100.5, + "blobType": new Uint8Array([1, 2, 3]), +} +rdbStore.insert("test", valueBucket, function (err, ret) { + if (err) { + console.info("Failed to insert data, err: " + err) + return + } + console.log("Inserted data successfully: " + ret) +}) +rdbStore.commit() ``` @@ -1453,18 +1482,22 @@ Commits the executed SQL statements. **Example** ```js - rdbStore.beginTransaction() - const valueBucket = { - "name": "lisi", - "age": 18, - "salary": 100.5, - "blobType": new Uint8Array([1, 2, 3]), - } - - rdbStore.insert("test", valueBucket, function (err, ret) { - console.log("insert done: " + ret) - }) - rdbStore.commit() +rdbStore.beginTransaction() +const valueBucket = { + "name": "lisi", + "age": 18, + "salary": 100.5, + "blobType": new Uint8Array([1, 2, 3]), +} + +rdbStore.insert("test", valueBucket, function (err, ret) { + if (err) { + console.info("Failed to insert data, err: " + err) + return + } + console.log("Inserted data successfully: " + ret) +}) +rdbStore.commit() ``` @@ -1478,22 +1511,26 @@ Rolls back the SQL statements that have been executed. **Example** ```js - try { - rdbStore.beginTransaction() - const valueBucket = { - "id": 1, - "name": "lisi", - "age": 18, - "salary": 100.5, - "blobType": new Uint8Array([1, 2, 3]), - } - rdbStore.insert("test", valueBucket, function (err, ret) { - console.log("insert done: " + ret) - }) - rdbStore.commit() - } catch (e) { - rdbStore.rollBack() - } +try { + rdbStore.beginTransaction() + const valueBucket = { + "id": 1, + "name": "lisi", + "age": 18, + "salary": 100.5, + "blobType": new Uint8Array([1, 2, 3]), + } + rdbStore.insert("test", valueBucket, function (err, ret) { + if (err) { + console.info("Failed to insert data, err: " + err) + return + } + console.log("Inserted data successfully: " + ret) + }) + rdbStore.commit() +} catch (e) { + rdbStore.rollBack() +} ``` @@ -1512,14 +1549,14 @@ Sets a list of distributed tables. This API uses a callback to return the result | callback | AsyncCallback<void> | Yes| Callback invoked to return the result.| **Example** - ```js - rdbStore.setDistributedTables(["EMPLOYEE"], function (err) { - if (err) { - console.info('setDistributedTables failed.') - return - } - console.info('setDistributedTables success.') - }) +```js +rdbStore.setDistributedTables(["EMPLOYEE"], function (err) { + if (err) { + console.info('setDistributedTables failed, err: ' + err) + return + } + console.info('setDistributedTables successful.') +}) ``` @@ -1542,14 +1579,14 @@ Sets a list of distributed tables. This API uses a promise to return the result. | Promise<void> | Promise used to return the result.| **Example** - ```js - let promiseset = rdbStore.setDistributedTables(["EMPLOYEE"]) - promiseset.then(() => { - console.info("setDistributedTables success.") - }).catch((err) => { - console.info("setDistributedTables failed.") - }) - ``` +```js +let promise = rdbStore.setDistributedTables(["EMPLOYEE"]) +promise.then(() => { + console.info("setDistributedTables successful.") +}).catch((err) => { + console.info("setDistributedTables failed, err: " + err) +}) +``` ### obtainDistributedTableName8+ @@ -1567,15 +1604,15 @@ Obtains the distributed table name for a remote device based on the local table | callback | AsyncCallback<string> | Yes| Callback invoked to return the result. If the operation succeeds, the distributed table name of the remote device is returned.| **Example** - ```js - rdbStore.obtainDistributedTableName(deviceId, "EMPLOYEE", function (err, tableName) { - if (err) { - console.info('obtainDistributedTableName failed.') - return - } - console.info('obtainDistributedTableName success, tableName=.' + tableName) - }) - ``` +```js +rdbStore.obtainDistributedTableName(deviceId, "EMPLOYEE", function (err, tableName) { + if (err) { + console.info('obtainDistributedTableName failed, err: ' + err) + return + } + console.info('obtainDistributedTableName successful, tableName=.' + tableName) +}) +``` ### obtainDistributedTableName8+ @@ -1598,14 +1635,14 @@ Obtains the distributed table name for a remote device based on the local table | Promise<string> | Promise used to return the result. If the operation succeeds, the distributed table name of the remote device is returned.| **Example** - ```js - let promiseDistr = rdbStore.obtainDistributedTableName(deviceId, "EMPLOYEE") - promiseDistr.then((tableName) => { - console.info('obtainDistributedTableName success, tableName=' + tableName) - }).catch((err) => { - console.info('obtainDistributedTableName failed.') - }) - ``` +```js +let promise = rdbStore.obtainDistributedTableName(deviceId, "EMPLOYEE") +promise.then((tableName) => { + console.info('obtainDistributedTableName successful, tableName=' + tableName) +}).catch((err) => { + console.info('obtainDistributedTableName failed, err: ' + err) +}) +``` ### sync8+ @@ -1623,20 +1660,20 @@ Synchronizes data between devices. This API uses a callback to return the result | callback | AsyncCallback<Array<[string, number]>> | Yes| Callback invoked to send the synchronization result to the caller.
**string** indicates the device ID.
**number** indicates the synchronization status of each device. The value **0** indicates a successful synchronization. Other values indicate a synchronization failure. | **Example** - ```js - let predicate = new rdb.RdbPredicates('EMPLOYEE') - predicate.inDevices(['12345678abcde']) - rdbStore.sync(rdb.SyncMode.SYNC_MODE_PUSH, predicate, function (err, result) { - if (err) { - console.log('sync failed') - return - } - console.log('sync done.') - for (let i = 0; i < result.length; i++) { - console.log('device=' + result[i][0] + ' status=' + result[i][1]) - } - }) - ``` +```js +let predicates = new rdb.RdbPredicates('EMPLOYEE') +predicates.inDevices(['12345678abcde']) +rdbStore.sync(rdb.SyncMode.SYNC_MODE_PUSH, predicates, function (err, result) { + if (err) { + console.log('sync failed, err: ' + err) + return + } + console.log('sync done.') + for (let i = 0; i < result.length; i++) { + console.log('device=' + result[i][0] + ' status=' + result[i][1]) + } +}) +``` ### sync8+ @@ -1660,19 +1697,19 @@ Synchronizes data between devices. This API uses a promise to return the result. | Promise<Array<[string, number]>> | Promise used to return the synchronization result to the caller.
**string** indicates the device ID.
**number** indicates the synchronization status of each device. The value **0** indicates a successful synchronization. Other values indicate a synchronization failure. | **Example** - ```js - let predicatesync = new data_rdb.RdbPredicates('EMPLOYEE') - predicatesync.inDevices(['12345678abcde']) - let promisesync = rdbStore.sync(data_rdb.SyncMode.SYNC_MODE_PUSH, predicatesync) - promisesync.then((result) =>{ - console.log('sync done.') - for (let i = 0; i < result.length; i++) { - console.log('device=' + result[i][0] + ' status=' + result[i][1]) - } - }).catch((err) => { - console.log('sync failed') - }) - ``` +```js +let predicates = new data_rdb.RdbPredicates('EMPLOYEE') +predicates.inDevices(['12345678abcde']) +let promise = rdbStore.sync(data_rdb.SyncMode.SYNC_MODE_PUSH, predicates) +promise.then((result) =>{ + console.log('sync done.') + for (let i = 0; i < result.length; i++) { + console.log('device=' + result[i][0] + ' status=' + result[i][1]) + } +}).catch((err) => { + console.log('sync failed') +}) +``` ### on('dataChange')8+ @@ -1691,18 +1728,18 @@ Registers an observer for this RDB store. When the data in the RDB store changes | observer | Callback<Array<string>> | Yes| Observer that listens for the data changes in the RDB store.| **Example** - ```js - function storeObserver(devices) { - for (let i = 0; i < devices.length; i++) { - console.log('device=' + devices[i] + ' data changed') - } - } - try { - rdbStore.on('dataChange', data_rdb.SubscribeType.SUBSCRIBE_TYPE_REMOTE, storeObserver) - } catch (err) { - console.log('register observer failed') - } - ``` +```js +function storeObserver(devices) { + for (let i = 0; i < devices.length; i++) { + console.log('device=' + devices[i] + ' data changed') + } +} +try { + rdbStore.on('dataChange', data_rdb.SubscribeType.SUBSCRIBE_TYPE_REMOTE, storeObserver) +} catch (err) { + console.log('Failed to register observer') +} +``` ### off('dataChange')8+ @@ -1721,19 +1758,18 @@ Deletes the specified observer of the RDB store. This API uses a callback to ret | observer | Callback<Array<string>> | Yes| Data change observer registered.| **Example** - - ```js - function storeObserver(devices) { - for (let i = 0; i < devices.length; i++) { - console.log('device=' + devices[i] + ' data changed') - } - } - try { - rdbStore.off('dataChange', data_rdb.SubscribeType.SUBSCRIBE_TYPE_REMOTE, storeObserver) - } catch (err) { - console.log('unregister observer failed') - } - ``` +```js +function storeObserver(devices) { + for (let i = 0; i < devices.length; i++) { + console.log('device=' + devices[i] + ' data changed') + } +} +try { + rdbStore.off('dataChange', data_rdb.SubscribeType.SUBSCRIBE_TYPE_REMOTE, storeObserver) +} catch (err) { + console.log('Failed to unregister observer') +} +``` ## StoreConfig diff --git a/en/application-dev/reference/apis/js-apis-data-resultset.md b/en/application-dev/reference/apis/js-apis-data-resultset.md index 3dca6cfcb0e84fdd90f9ce7b0cb6c79432d95eda..613e793255ded14a1ae050bdf4504e402b52b941 100644 --- a/en/application-dev/reference/apis/js-apis-data-resultset.md +++ b/en/application-dev/reference/apis/js-apis-data-resultset.md @@ -1,6 +1,6 @@ # Result Set -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **NOTE**
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. 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 844b24576aa7a48f0b26207aa7886c7fb668e299..63ae9d95bc7da1a827030de4e644d44d68c7235c 100644 --- a/en/application-dev/reference/apis/js-apis-data-storage.md +++ b/en/application-dev/reference/apis/js-apis-data-storage.md @@ -3,7 +3,7 @@ Lightweight storage provides applications with data processing capability and allows applications to perform lightweight data storage and query. Data is stored in key-value (KV) pairs. Keys are of the string type, and values can be of the number, string, or Boolean type. -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **NOTE**
> > - The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. > @@ -30,7 +30,7 @@ import dataStorage from '@ohos.data.storage'; getStorageSync(path: string): Storage -Reads a file and loads the data to the **Storage** instance in synchronous mode. +Reads the specified file and load its data to the **Storage** instance for data operations. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -67,7 +67,7 @@ Reads a file and loads the data to the **Storage** instance in synchronous mode. getStorage(path: string, callback: AsyncCallback<Storage>): void -Reads a file and loads the data to the **Storage** instance. This API uses an asynchronous callback to return the execution result. +Reads the specified file and loads its data to the **Storage** instance for data operations. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -105,7 +105,7 @@ Reads a file and loads the data to the **Storage** instance. This API uses an as getStorage(path: string): Promise<Storage> -Reads a file and loads the data to the **Storage** instance. This API uses a promise to return the execution result. +Reads the specified file and loads its data to the **Storage** instance for data operations. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -146,7 +146,7 @@ Reads a file and loads the data to the **Storage** instance. This API uses a pro deleteStorageSync(path: string): void -Deletes the singleton **Storage** instance of a file from the memory, and deletes the specified file, its backup file, and damaged files. After the specified files are deleted, the **Storage** instance cannot be used for data operations. Otherwise, data inconsistency will occur. This API uses a synchronous mode. +Deletes the singleton **Storage** instance of a file from the memory, and deletes the specified file, its backup file, and damaged files. After the specified files are deleted, the **Storage** instance cannot be used for data operations. Otherwise, data inconsistency will occur. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -165,7 +165,7 @@ Deletes the singleton **Storage** instance of a file from the memory, and delete deleteStorage(path: string, callback: AsyncCallback<void>): void -Deletes the singleton **Storage** instance of a file from the memory, and deletes the specified file, its backup file, and damaged files. After the specified files are deleted, the **Storage** instance cannot be used for data operations. Otherwise, data inconsistency will occur. This API uses an asynchronous callback to return the execution result. +Deletes the singleton **Storage** instance of a file from the memory, and deletes the specified file, its backup file, and damaged files. After the specified files are deleted, the **Storage** instance cannot be used for data operations. Otherwise, data inconsistency will occur. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -191,7 +191,7 @@ Deletes the singleton **Storage** instance of a file from the memory, and delete deleteStorage(path: string): Promise<void> -Deletes the singleton **Storage** instance of a file from the memory, and deletes the specified file, its backup file, and damaged files. After the specified files are deleted, the **Storage** instance cannot be used for data operations. Otherwise, data inconsistency will occur. This API uses a promise to return the execution result. +Deletes the singleton **Storage** instance of a file from the memory, and deletes the specified file, its backup file, and damaged files. After the specified files are deleted, the **Storage** instance cannot be used for data operations. Otherwise, data inconsistency will occur. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -222,8 +222,6 @@ removeStorageFromCacheSync(path: string): void Removes the singleton **Storage** instance of a file from the cache. The removed instance cannot be used for data operations. Otherwise, data inconsistency will occur. -This API uses a synchronous mode. - **System capability**: SystemCapability.DistributedDataManager.Preferences.Core **Parameters** @@ -241,9 +239,7 @@ This API uses a synchronous mode. removeStorageFromCache(path: string, callback: AsyncCallback<void>): void -Removes the singleton **Storage** instance of a file from the cache. The removed instance cannot be used for data operations. Otherwise, data inconsistency will occur. - -This API uses an asynchronous callback to return the result. +Removes the singleton **Storage** instance of a file from the cache. The removed instance cannot be used for data operations. Otherwise, data inconsistency will occur. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -269,9 +265,7 @@ This API uses an asynchronous callback to return the result. removeStorageFromCache(path: string): Promise<void> -Removes the singleton **Storage** instance of a file from the cache. The removed instance cannot be used for data operations. Otherwise, data inconsistency will occur. - -This API uses a promise to return the result. +Removes the singleton **Storage** instance of a file from the cache. The removed instance cannot be used for data operations. Otherwise, data inconsistency will occur. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -307,8 +301,6 @@ getSync(key: string, defValue: ValueType): ValueType Obtains the value corresponding to a key. If the value is null or not in the default value format, the default value is returned. -This API uses a synchronous mode. - **System capability**: SystemCapability.DistributedDataManager.Preferences.Core **Parameters** @@ -333,9 +325,7 @@ This API uses a synchronous mode. get(key: string, defValue: ValueType, callback: AsyncCallback<ValueType>): void -Obtains the value corresponding to a key. If the value is null or not in the default value format, the default value is returned. - -This API uses an asynchronous callback to return the result. +Obtains the value corresponding to a key. If the value is null or not in the default value format, the default value is returned. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -362,9 +352,7 @@ This API uses an asynchronous callback to return the result. get(key: string, defValue: ValueType): Promise<ValueType> -Obtains the value corresponding to a key. If the value is null or not in the default value format, the default value is returned. - -This API uses a promise to return the result. +Obtains the value corresponding to a key. If the value is null or not in the default value format, the default value is returned. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -397,8 +385,6 @@ putSync(key: string, value: ValueType): void Obtains the **Storage** instance corresponding to the specified file, writes data to the **Storage** instance using a **Storage** API, and saves the modification using **flush()** or **flushSync()**. -This API uses a synchronous mode. - **System capability**: SystemCapability.DistributedDataManager.Preferences.Core **Parameters** @@ -417,9 +403,7 @@ This API uses a synchronous mode. put(key: string, value: ValueType, callback: AsyncCallback<void>): void -Obtains the **Storage** instance corresponding to the specified file, writes data to the **Storage** instance using a **Storage** API, and saves the modification using **flush()** or **flushSync()**. - -This API uses an asynchronous callback to return the result. +Obtains the **Storage** instance corresponding to the specified file, writes data to the **Storage** instance using a **Storage** API, and saves the modification using **flush()** or **flushSync()**. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -446,9 +430,7 @@ This API uses an asynchronous callback to return the result. put(key: string, value: ValueType): Promise<void> -Obtains the **Storage** instance corresponding to the specified file, writes data to the **Storage** instance using a **Storage** API, and saves the modification using **flush()** or **flushSync()**. - -This API uses a promise to return the result. +Obtains the **Storage** instance corresponding to the specified file, writes data to the **Storage** instance using a **Storage** API, and saves the modification using **flush()** or **flushSync()**. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -480,8 +462,6 @@ hasSync(key: string): boolean Checks whether the storage object contains data with a given key. -This API uses a synchronous mode. - **System capability**: SystemCapability.DistributedDataManager.Preferences.Core **Parameters** @@ -507,9 +487,7 @@ This API uses a synchronous mode. has(key: string, callback: AsyncCallback<boolean>): boolean -Checks whether the storage object contains data with a given key. - -This API uses an asynchronous callback to return the result. +Checks whether the storage object contains data with a given key. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -542,9 +520,7 @@ This API uses an asynchronous callback to return the result. has(key: string): Promise<boolean> -Checks whether the storage object contains data with a given key. - -This API uses a promise to return the result. +Checks whether the storage object contains data with a given key. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -577,8 +553,6 @@ deleteSync(key: string): void Deletes data with the specified key from this storage object. -This API uses a synchronous mode. - **System capability**: SystemCapability.DistributedDataManager.Preferences.Core **Parameters** @@ -592,13 +566,11 @@ This API uses a synchronous mode. ``` -### deletej +### delete delete(key: string, callback: AsyncCallback<void>): void -Deletes data with the specified key from this storage object. - -This API uses an asynchronous callback to return the result. +Deletes data with the specified key from this storage object. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -624,9 +596,7 @@ This API uses an asynchronous callback to return the result. delete(key: string): Promise<void> -Deletes data with the specified key from this storage object. - -This API uses a promise to return the result. +Deletes data with the specified key from this storage object. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -657,8 +627,6 @@ flushSync(): void Saves the modification of this object to the **Storage** instance and synchronizes the modification to the file. -This API uses a synchronous mode. - **System capability**: SystemCapability.DistributedDataManager.Preferences.Core **Example** @@ -671,9 +639,7 @@ This API uses a synchronous mode. flush(callback: AsyncCallback<void>): void -Saves the modification of this object to the **Storage** instance and synchronizes the modification to the file. - -This API uses an asynchronous callback to return the result. +Saves the modification of this object to the **Storage** instance and synchronizes the modification to the file. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -698,9 +664,7 @@ This API uses an asynchronous callback to return the result. flush(): Promise<void> -Saves the modification of this object to the **Storage** instance and synchronizes the modification to the file. - -This API uses a promise to return the result. +Saves the modification of this object to the **Storage** instance and synchronizes the modification to the file. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -726,8 +690,6 @@ clearSync(): void Clears this **Storage** object. -This API uses a synchronous mode. - **System capability**: SystemCapability.DistributedDataManager.Preferences.Core **Example** @@ -740,9 +702,7 @@ This API uses a synchronous mode. clear(callback: AsyncCallback<void>): void -Clears this **Storage** object. - -This API uses an asynchronous callback to return the result. +Clears this **Storage** object. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core @@ -767,9 +727,7 @@ This API uses an asynchronous callback to return the result. clear(): Promise<void> -Clears this **Storage** object. - -This API uses a promise to return the result. +Clears this **Storage** object. This API uses a promise to return the result. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core diff --git a/en/application-dev/reference/apis/js-apis-distributed-data.md b/en/application-dev/reference/apis/js-apis-distributed-data.md index 8f5b800d57488426664e514675c1af28864e962f..6bbe4a0111f7fa6d409457e705af60cf6d0376c7 100644 --- a/en/application-dev/reference/apis/js-apis-distributed-data.md +++ b/en/application-dev/reference/apis/js-apis-distributed-data.md @@ -2,7 +2,7 @@ Distributed data management provides collaboration between databases of different devices for applications. The APIs provided by distributed data management can be used to save data to the distributed database and perform operations such as adding, deleting, modifying, and querying data in the distributed database. ->![](../../public_sys-resources/icon-note.gif) **NOTE**
+>**NOTE**
>The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -2922,6 +2922,7 @@ These value types can be used only by internal applications. | BOOLEAN |4 |Boolean. | | DOUBLE |5 |Double (double-precision floating point). | + ## SingleKVStore Provides methods to query and synchronize data in a single KV store. This class inherits from **KVStore**. Before calling any method in **SingleKVStore**, you must use [getKVStore](#getkvstore) to obtain a **SingleKVStore** object. @@ -3447,7 +3448,7 @@ Closes the **KvStoreResultSet** object obtained by **getResultSet**. This API us | Name | Type| Mandatory | Description | | ----- | ------ | ---- | ----------------------- | | resultSet |[KvStoreResultSet](#kvstoreresultset8) | Yes |**KvStoreResultSet** object to close. | -| callback |AsyncCallback<void> | Yes |Callback used to return the execution result. | +| callback |AsyncCallback<void> | Yes |Callback used to return the result. | **Example** diff --git a/en/application-dev/reference/apis/js-apis-document.md b/en/application-dev/reference/apis/js-apis-document.md index 72a821e56aadea8f326df19c40583c4398465d46..7895868cf0fa4e61104b211cda4a33728c943b06 100644 --- a/en/application-dev/reference/apis/js-apis-document.md +++ b/en/application-dev/reference/apis/js-apis-document.md @@ -1,6 +1,6 @@ # File Interaction -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **NOTE**
> - The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. > - The APIs of this module will be deprecated and are not recommended for use. An exception will be thrown if any of the APIs is called. ## Modules to Import @@ -19,15 +19,15 @@ Chooses a file of the specified type using the file manager. This API uses a pro - Parameters - | Name| Type | Mandatory | Description | - | ------ | ------ | ---- | ---------------------------- | - | type | string[] | No | Type of the file to choose. | + | Name| Type | Mandatory | Description | + | ------ | ------ | ---- | ---------------------------- | + | type | string[] | No | Type of the file to choose. | - Return value - | Type | Description | - | --------------------- | -------------- | - | Promise<string> | Promise used to return the result. An error code is returned. | + | Type | Description | + | --------------------- | -------------- | + | Promise<string> | Promise used to return the result. An error code is returned. | - Example @@ -44,9 +44,9 @@ Chooses a file using the file manager. This API uses an asynchronous callback to - Parameters - | Name | Type | Mandatory | Description | - | -------- | --------------------------- | ---- | ---------------------------- | - | callback | AsyncCallback<string> | Yes | Callback used to return the result. An error code is returned. | + | Name | Type | Mandatory | Description | + | -------- | --------------------------- | ---- | ---------------------------- | + | callback | AsyncCallback<string> | Yes | Callback used to return the result. An error code is returned. | - Example @@ -65,10 +65,10 @@ Chooses a file of the specified type using the file manager. This API uses an as - Parameters - | Name | Type | Mandatory | Description | - | -------- | --------------------------- | ---- | ---------------------------- | - | type | string[] | No | Type of the file to choose. | - | callback | AsyncCallback<string> | Yes | Callback used to return the result. An error code is returned. | + | Name | Type | Mandatory | Description | + | -------- | --------------------------- | ---- | ---------------------------- | + | type | string[] | No | Type of the file to choose. | + | callback | AsyncCallback<string> | Yes | Callback used to return the result. An error code is returned. | - Example @@ -88,16 +88,16 @@ Opens a file. This API uses a promise to return the result. - Parameters - | Name | Type | Mandatory | Description | - | ---- | ------ | ---- | ---------------------------- | - | uri | string | Yes | URI of the file to open. | - | type | string | Yes | Type of the file to open. | + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ---------------------------- | + | uri | string | Yes | URI of the file to open. | + | type | string | Yes | Type of the file to open. | - Return value - | Type | Description | - | --------------------- | ------------ | - | Promise<void> | Promise used to return the result. An error code is returned. | + | Type | Description | + | --------------------- | ------------ | + | Promise<void> | Promise used to return the result. An error code is returned. | - Example @@ -115,11 +115,11 @@ Opens a file. This API uses an asynchronous callback to return the result. - Parameters - | Name | Type | Mandatory | Description | - | -------- | --------------------------- | ---- | ---------------------------- | - | uri | string | Yes | URI of the file to open. | - | type | string | Yes | Type of the file to open. | - | callback | AsyncCallback<void> | Yes | Callback used to return the result. An error code is returned. | + | Name | Type | Mandatory | Description | + | -------- | --------------------------- | ---- | ---------------------------- | + | uri | string | Yes | URI of the file to open. | + | type | string | Yes | Type of the file to open. | + | callback | AsyncCallback<void> | Yes | Callback used to return the result. An error code is returned. | - Example diff --git a/en/application-dev/reference/apis/js-apis-emitter.md b/en/application-dev/reference/apis/js-apis-emitter.md index 3d2b457c610cd2cff351ca48d3e1e5527e6a8a06..fa54f6739279745a1f7538fd32abf0fca6402711 100644 --- a/en/application-dev/reference/apis/js-apis-emitter.md +++ b/en/application-dev/reference/apis/js-apis-emitter.md @@ -1,6 +1,6 @@ # Emitter -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **NOTE**
> The initial APIs of this module are supported since API version 7. ## Modules to Import @@ -17,12 +17,12 @@ None Enumerates the event emit priority levels. -| Name | Value | Description | -| --------- | ---- | ------------------------------------------------- | -| IMMEDIATE | 0 | The event will be emitted immediately.
**System capability**: SystemCapability.Notification.Emitter | -| HIGH | 1 | The event will be emitted before low-priority events.
**System capability**: SystemCapability.Notification.Emitter | -| LOW | 2 | The event will be emitted before idle-priority events. By default, an event is in LOW priority.
**System capability**: SystemCapability.Notification.Emitter | -| IDLE | 3 | The event will be emitted after all the other events.
**System capability**: SystemCapability.Notification.Emitter | + | Name | Value | Description | + | --------- | ---- | ------------------------------------------------- | + | IMMEDIATE | 0 | The event will be emitted immediately.
**System capability**: SystemCapability.Notification.Emitter | + | HIGH | 1 | The event will be emitted before low-priority events.
**System capability**: SystemCapability.Notification.Emitter | + | LOW | 2 | The event will be emitted before idle-priority events. By default, an event is in LOW priority.
**System capability**: SystemCapability.Notification.Emitter | + | IDLE | 3 | The event will be emitted after all the other events.
**System capability**: SystemCapability.Notification.Emitter | ## emitter.on @@ -34,10 +34,10 @@ Subscribes to an event in persistent manner. This API uses a callback to return **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ----------------------------------- | ---- | ------------------------ | -| event | [InnerEvent](#innerevent) | Yes | Event to subscribe to in persistent manner. | -| callback | Callback\<[EventData](#eventdata)\> | Yes | Callback used to return the event. | + | Name | Type | Mandatory | Description | + | -------- | ----------------------------------- | ---- | ------------------------ | + | event | [InnerEvent](#innerevent) | Yes | Event to subscribe to in persistent manner. | + | callback | Callback\<[EventData](#eventdata)\> | Yes | Callback used to return the event. | **Example** @@ -61,10 +61,10 @@ Subscribes to an event in one-shot manner and unsubscribes from it after the eve **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ----------------------------------- | ---- | ------------------------ | -| event | [InnerEvent](#innerevent) | Yes | Event to subscribe to in one-shot manner. | -| callback | Callback\<[EventData](#eventdata)\> | Yes | Callback used to return the event. | + | Name | Type | Mandatory | Description | + | -------- | ----------------------------------- | ---- | ------------------------ | + | event | [InnerEvent](#innerevent) | Yes | Event to subscribe to in one-shot manner. | + | callback | Callback\<[EventData](#eventdata)\> | Yes | Callback used to return the event. | **Example** @@ -88,9 +88,9 @@ Unsubscribes from an event. **Parameters** -| Name | Type | Mandatory | Description | -| ------- | ------ | ---- | ------ | -| eventId | number | Yes | Event ID. | + | Name | Type | Mandatory | Description | + | ------- | ------ | ---- | ------ | + | eventId | number | Yes | Event ID. | **Example** @@ -108,10 +108,10 @@ Emits an event to the event queue. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------------------------- | ---- | -------------- | -| event | [InnerEvent](#innerevent) | Yes | Event to emit. | -| data | [EventData](#eventdata) | No | Data carried by the event. | + | Name | Type | Mandatory | Description | + | ------ | ------------------------- | ---- | -------------- | + | event | [InnerEvent](#innerevent) | Yes | Event to emit. | + | data | [EventData](#eventdata) | No | Data carried by the event. | **Example** @@ -132,15 +132,15 @@ emitter.emit(innerEvent, eventData); Describes an intra-process event. -| Name | Type | Readable| Writable| Description | -| -------- | ------------------------------- | ---- | ---- | ---------------------------------- | -| eventId | number | Yes | Yes | Event ID, which is used to identify an event.
**System capability**: SystemCapability.Notification.Emitter | -| priority | [EventPriority](#eventpriority) | Yes | Yes | Emit priority of the event.
**System capability**: SystemCapability.Notification.Emitter | + | Name | Type | Readable | Writable | Description | + | -------- | ------------------------------- | ---- | ---- | ---------------------------------- | + | eventId | number | Yes | Yes | Event ID, which is used to identify an event.
**System capability**: SystemCapability.Notification.Emitter | + | priority | [EventPriority](#eventpriority) | Yes | Yes | Emit priority of the event.
**System capability**: SystemCapability.Notification.Emitter | ## EventData Describes the data passed in the event. -| Name| Type | Readable| Writable| Description | -| ---- | ------------------ | ---- | ---- | -------------- | -| data | [key: string]: any | Yes | Yes | Data carried by the event. The data type can be String, Integer, or Boolean.
**System capability**: SystemCapability.Notification.Emitter | + | Name | Type | Readable | Writable | Description | + | ---- | ------------------ | ---- | ---- | -------------- | + | data | [key: string]: any | Yes | Yes | Data carried by the event. The data type can be String, Integer, or Boolean.
**System capability**: SystemCapability.Notification.Emitter | diff --git a/en/application-dev/reference/apis/js-apis-enterprise-device-manager.md b/en/application-dev/reference/apis/js-apis-enterprise-device-manager.md index 3e5762750b71ceec5c3b6d852ecec054ef29ad1e..869472d43c046a68cd3d50cfe262b424b660dd0d 100644 --- a/en/application-dev/reference/apis/js-apis-enterprise-device-manager.md +++ b/en/application-dev/reference/apis/js-apis-enterprise-device-manager.md @@ -1,7 +1,6 @@ # Enterprise Device Management -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** -> +> **NOTE**
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -28,12 +27,12 @@ SystemCapability.Customation.EnterpriseDeviceManager **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. | -| enterpriseInfo | [EnterpriseInfo](#EnterpriseInfo) | Yes | Enterprise information of the device administrator application.| -| type | [AdminType](#AdminType) | Yes| Type of the device administrator to activate.| -| callback | AsyncCallback\ | Yes| Callback used to return the result.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. | + | enterpriseInfo | [EnterpriseInfo](#EnterpriseInfo) | Yes | Enterprise information of the device administrator application. | + | type | [AdminType](#AdminType) | Yes | Type of the device administrator to activate. | + | callback | AsyncCallback\ | Yes | Callback used to return the result. | **Example** @@ -71,17 +70,17 @@ SystemCapability.Customation.EnterpriseDeviceManager **Parameters** -| Name | Type | Mandatory| Description | -| -------------- | ---------------------------------------------- | ---- | ------------------------ | -| admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. | -| enterpriseInfo | [EnterpriseInfo](#EnterpriseInfo) | Yes | Enterprise information of the device administrator application.| -| type | [AdminType](#AdminType) | Yes | Type of the device administrator to activate. | + | Name | Type | Mandatory | Description | + | -------------- | ---------------------------------------------- | ---- | ------------------------ | + | admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. | + | enterpriseInfo | [EnterpriseInfo](#EnterpriseInfo) | Yes | Enterprise information of the device administrator application. | + | type | [AdminType](#AdminType) | Yes | Type of the device administrator to activate. | **Return value** -| Type | Description | -| ----------------- | --------------------------- | -| Promise\ | Promise used to return the result.| + | Type | Description | + | ----------------- | --------------------------- | + | Promise\ | Promise used to return the result. | **Example** @@ -118,10 +117,10 @@ SystemCapability.Customation.EnterpriseDeviceManager **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ---------------------------------------------- | ---- | ------------------------------ | -| admin | [Want](js-apis-application-Want.md) | Yes | Device common administrator application. | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| + | Name | Type | Mandatory | Description | + | -------- | ---------------------------------------------- | ---- | ------------------------------ | + | admin | [Want](js-apis-application-Want.md) | Yes | Device common administrator application. | + | callback | AsyncCallback\ | Yes | Callback used to return the result. | **Example** @@ -157,15 +156,15 @@ SystemCapability.Customation.EnterpriseDeviceManager **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ---------------------------------------------- | ---- | ------------------ | -| admin | [Want](js-apis-application-Want.md) | Yes | Device common administrator application.| + | Name | Type | Mandatory | Description | + | ------ | ---------------------------------------------- | ---- | ------------------ | + | admin | [Want](js-apis-application-Want.md) | Yes | Device common administrator application. | **Return value** -| Type | Description | -| ----------------- | --------------------------- | -| Promise\ | Promise used to return the result.| + | Type | Description | + | ----------------- | --------------------------- | + | Promise\ | Promise used to return the result. | **Example** @@ -193,10 +192,10 @@ SystemCapability.Customation.EnterpriseDeviceManager **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | ----------------------- | ---- | ------------------------------ | -| bundleName | String | Yes | Bundle name of a device super administrator application. | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| + | Name | Type | Mandatory | Description | + | ---------- | ----------------------- | ---- | ------------------------------ | + | bundleName | String | Yes | Bundle name of a device super administrator application. | + | callback | AsyncCallback\ | Yes | Callback used to return the result. | **Example** @@ -223,15 +222,15 @@ SystemCapability.Customation.EnterpriseDeviceManager **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | ------ | ---- | ------------------------ | -| bundleName | String | Yes | Bundle name of a device super administrator application.| + | Name | Type | Mandatory | Description | + | ---------- | ------ | ---- | ------------------------ | + | bundleName | String | Yes | Bundle name of a device super administrator application. | **Return value** -| Type | Description | -| ----------------- | --------------------------- | -| Promise\ | Promise used to return the result.| + | Type | Description | + | ----------------- | --------------------------- | + | Promise\ | Promise used to return the result. | **Example** @@ -256,10 +255,10 @@ SystemCapability.Customation.EnterpriseDeviceManager **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ---------------------------------------------- | ---- | -------------------------------- | -| admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| + | Name | Type | Mandatory | Description | + | -------- | ---------------------------------------------- | ---- | -------------------------------- | + | admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. | + | callback | AsyncCallback\ | Yes | Callback used to return the result. | **Example** @@ -291,15 +290,15 @@ SystemCapability.Customation.EnterpriseDeviceManager **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ---------------------------------------------- | ---- | -------------- | -| admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application.| + | Name | Type | Mandatory | Description | + | ------ | ---------------------------------------------- | ---- | -------------- | + | admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. | **Return value** -| Type | Description | -| ----------------- | ------------------------------- | -| Promise\ | Promise used to return the result.| + | Type | Description | + | ----------------- | ------------------------------- | + | Promise\ | Promise used to return the result. | **Example** @@ -327,10 +326,10 @@ SystemCapability.Customation.EnterpriseDeviceManager **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | ----------------------- | ---- | -------------------------------- | -| bundleName | String | Yes | Bundle name of a device super administrator application. | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| + | Name | Type | Mandatory | Description | + | ---------- | ----------------------- | ---- | -------------------------------- | + | bundleName | String | Yes | Bundle name of a device super administrator application. | + | callback | AsyncCallback\ | Yes | Callback used to return the result. | **Example** @@ -359,15 +358,15 @@ SystemCapability.Customation.EnterpriseDeviceManager **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | ------ | ---- | ------------------ | -| bundleName | String | Yes | Bundle name of a device super administrator application.| + | Name | Type | Mandatory | Description | + | ---------- | ------ | ---- | ------------------ | + | bundleName | String | Yes | Bundle name of a device super administrator application. | **Return value** -| Type | Description | -| ----------------- | ------------------------------- | -| Promise\ | Promise used to return the result.| + | Type | Description | + | ----------------- | ------------------------------- | + | Promise\ | Promise used to return the result. | **Example** @@ -392,9 +391,9 @@ SystemCapability.Customation.EnterpriseDeviceManager **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| callback | AsyncCallback; | Callback used to return the result.| + | Type | Description | + | ------------------ | ----------------------------------- | + | Promise\; | Callback used to return the result. | **Example** @@ -545,10 +544,10 @@ SystemCapability.Customation.EnterpriseDeviceManager **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ------------------------------------------------------ | ---- | ---------------------------------------- | -| admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. | -| callback | AsyncCallback<[EnterpriseInfo](#EnterpriseInfo)> | Yes | Callback used to return the enterprise information of the device administrator application.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------------------------------------ | ---- | ---------------------------------------- | + | admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. | + | callback | AsyncCallback<[EnterpriseInfo](#EnterpriseInfo)> | Yes | Callback used to return the enterprise information of the device administrator application. | **Example** @@ -570,7 +569,7 @@ enterpriseDeviceManager.getEnterpriseInfo(wantTemp, (error, result) => { ## enterpriseDeviceManager.getEnterpriseInfo -getDeviceSettingsManager(admin: Want): Promise<EnterpriseInfo> +getEnterpriseInfo(admin: Want): Promise<EnterpriseInfo> Obtains the enterprise information of a device administrator application. This API uses a promise to return the result. @@ -580,15 +579,15 @@ SystemCapability.Customation.EnterpriseDeviceManager **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ---------------------------------------------- | ---- | -------------- | -| admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application.| + | Name | Type | Mandatory | Description | + | ------ | ---------------------------------------------- | ---- | -------------- | + | admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. | **Return value** -| Type | Description | -| ------------------------------------------------ | ------------------------------------------- | -| Promise<[EnterpriseInfo](#EnterpriseInfo)> | Promise used to return the enterprise information of the device administrator application.| + | Type | Description | + | ------------------------------------------------ | ------------------------------------------- | + | Promise<[EnterpriseInfo](#EnterpriseInfo)> | Promise used to return the enterprise information of the device administrator application. | **Example** @@ -613,10 +612,10 @@ Describes the enterprise information of a device administrator application. SystemCapability.Customation.EnterpriseDeviceManager -| Name | Readable/Writable| Type | Mandatory| Description | -| ----------- | -------- | ------ | ---- | ---------------------------------- | -| name | Read only | string | Yes | Name of the enterprise to which the device administrator application belongs.| -| description | Read only | string | Yes | Description of the enterprise to which the device administrator application belongs.| + | Name | Readable/Writable | Type | Mandatory | Description | + | ----------- | -------- | ------ | ---- | ---------------------------------- | + | name | Read only | string | Yes | Name of the enterprise to which the device administrator application belongs. | + | description | Read only | string | Yes | Description of the enterprise to which the device administrator application belongs. | ## AdminType @@ -627,7 +626,7 @@ Enumerates the administrator types of the device administrator application. SystemCapability.Customation.EnterpriseDeviceManager -| Name| Default Value| Description| -| -------- | -------- | -------- | -| ADMIN_TYPE_NORMAL | 0x00 | Common administrator.| -| ADMIN_TYPE_SUPER | 0x01 | Super administrator.| + | Name | Default Value | Description | + | -------- | -------- | -------- | + | ADMIN_TYPE_NORMAL | 0x00 | Common administrator. | + | ADMIN_TYPE_SUPER | 0x01 | Super administrator. | diff --git a/en/application-dev/reference/apis/js-apis-eventhub.md b/en/application-dev/reference/apis/js-apis-eventhub.md index 02e6f143f1527062aff5bf6d21b34889127239e8..b7afbb435c747c4b411aeaa72fb1806c47b39f60 100644 --- a/en/application-dev/reference/apis/js-apis-eventhub.md +++ b/en/application-dev/reference/apis/js-apis-eventhub.md @@ -1,6 +1,6 @@ # EventHub -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **NOTE**
> The initial APIs of this module are supported since API 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -34,10 +34,10 @@ Subscribes to an event. **Parameters** - | Name| Type| Mandatory| Description | - | -------- | -------- | -------- | -------- | - | event | string | Yes| Event name. | - | callback | Function | Yes| Callback invoked when the event is triggered. | + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | event | string | Yes | Event name. | + | callback | Function | Yes | Callback invoked when the event is triggered. | **Example** @@ -72,10 +72,10 @@ Unsubscribes from an event. If **callback** is specified, this API unsubscribes **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | event | string | Yes| Event name. | - | callback | Function | No | Callback for the event. If **callback** is unspecified, all callbacks of the event are unsubscribed. | + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | event | string | Yes | Event name. | + | callback | Function | No | Callback for the event. If **callback** is unspecified, all callbacks of the event are unsubscribed. | **Example** @@ -110,10 +110,10 @@ Triggers an event. **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | event | string | Yes| Event name. | - | ...args | Object[] | Yes| Variable parameters, which are passed to the callback when the event is triggered. | + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | event | string | Yes | Event name. | + | ...args | Object[] | Yes | Variable parameters, which are passed to the callback when the event is triggered. | **Example** diff --git a/en/application-dev/reference/apis/js-apis-fileio.md b/en/application-dev/reference/apis/js-apis-fileio.md index 09f43ce1dadc25d4c5f99b8b65933b470084b6ff..57543a8a185d1c364f6c9abbb5fc4f0f19d89e8e 100644 --- a/en/application-dev/reference/apis/js-apis-fileio.md +++ b/en/application-dev/reference/apis/js-apis-fileio.md @@ -1,8 +1,15 @@ # File Management -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **NOTE**
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. +This module provides common file storage functions. It provides the following JavaScript I/O APIs, including: + +- Basic APIs for file management +- Basic APIs for directory management +- Statistical APIs for obtaining file information +- Stream APIs for reading and writing files + ## Modules to Import ```js @@ -10,11 +17,6 @@ import fileio from '@ohos.fileio'; ``` -## Required Permissions - -None - - ## Guidelines Before using this module to perform operations on a file or directory, obtain the absolute path of the file or directory. For details, see [getOrCreateLocalDir of the Context module](js-apis-Context.md). @@ -40,21 +42,23 @@ let fd = fileio.openSync(path); stat(path: string): Promise<Stat> -Asynchronously obtains file information. This method uses a promise to return the result. +Asynchronously obtains file information. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** + | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ----------- | | path | string | Yes | Absolute path of the target file.| -- Return value +**Return value** + | Type | Description | | ---------------------------- | ---------- | | Promise<[Stat](#stat)> | Promise used to return the file information obtained.| -- Example +**Example** ```js fileio.stat(path).then(function(stat){ console.info("getFileInfo successfully:"+ JSON.stringify(stat)); @@ -68,17 +72,17 @@ Asynchronously obtains file information. This method uses a promise to return th stat(path:string, callback:AsyncCallback<Stat>): void -Asynchronously obtains file information. This method uses a callback to return the result. +Asynchronously obtains file information. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ---------------------------------- | ---- | --------------- | | path | string | Yes | Absolute path of the target file. | | callback | AsyncCallback<[Stat](#stat)> | Yes | Callback invoked to return the file information obtained.| -- Example +**Example** ```js fileio.stat(path, function (err, stat) { // Example code in Stat @@ -94,18 +98,18 @@ Synchronously obtains file information. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ----------- | | path | string | Yes | Absolute path of the target file.| -- Return value +**Return value** | Type | Description | | ------------- | ---------- | | [Stat](#stat) | File information obtained.| -- Example +**Example** ```js let stat = fileio.statSync(path); // Example code in Stat @@ -116,21 +120,21 @@ Synchronously obtains file information. opendir(path: string): Promise<Dir> -Asynchronously opens a directory. This method uses a promise to return the result. +Asynchronously opens a directory. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ------------- | | path | string | Yes | Absolute path of the directory to open.| -- Return value +**Return value** | Type | Description | | -------------------------- | -------- | | Promise<[Dir](#dir)> | A **Dir** instance corresponding to the directory.| -- Example +**Example** ```js fileio.opendir(path).then(function(dir){ console.info("opendir successfully:"+ JSON.stringify(dir)); @@ -144,17 +148,18 @@ Asynchronously opens a directory. This method uses a promise to return the resul opendir(path: string, callback: AsyncCallback<Dir>): void -Asynchronously opens a directory. This method uses a callback to return the result. +Asynchronously opens a directory. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** + | Name | Type | Mandatory | Description | | -------- | -------------------------------- | ---- | -------------- | | path | string | Yes | Absolute path of the directory to open. | | callback | AsyncCallback<[Dir](#dir)> | Yes | Callback invoked when the directory is open asynchronously.| -- Example +**Example** ```js fileio.opendir(path, function (err, dir) { // Example code in Dir struct @@ -172,17 +177,18 @@ Synchronously opens a directory. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** + | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ------------- | | path | string | Yes | Absolute path of the directory to open.| -- Return value +**Return value** | Type | Description | | ----------- | -------- | | [Dir](#dir) | A **Dir** instance corresponding to the directory.| -- Example +**Example** ```js let dir = fileio.opendirSync(path); // Example code in Dir struct @@ -194,22 +200,23 @@ Synchronously opens a directory. access(path: string, mode?: number): Promise<void> -Asynchronously checks whether the current process can access a file. This method uses a promise to return the result. +Asynchronously checks whether the current process can access a file. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** + | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ---------------------------------------- | | path | string | Yes | Absolute path of the target file. | | mode | number | No | Options for accessing the file. You can specify multiple options, separated with a bitwise OR operator (|). The default value is **0**.
The options are as follows:
- **0**: check whether the file exists.
- **1**: check whether the current process has the execute permission on the file.
- **2**: check whether the current process has the write permission on the file.
- **4**: check whether the current process has the read permission on the file.| -- Return value +**Return value** | Type | Description | | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result. An empty value is returned.| -- Example +**Example** ```js fileio.access(path).then(function() { console.info("access successfully"); @@ -223,18 +230,18 @@ Asynchronously checks whether the current process can access a file. This method access(path: string, mode: number, callback: AsyncCallback<void>): void -Asynchronously checks whether the current process can access a file. This method uses a callback to return the result. +Asynchronously checks whether the current process can access a file. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ------------------------- | ---- | ---------------------------------------- | | path | string | Yes | Absolute path of the target file. | | mode | number | No | Options for accessing the file. You can specify multiple options, separated with a bitwise OR operator (|). The default value is **0**.
The options are as follows:
- **0**: check whether the file exists.
- **1**: check whether the current process has the execute permission on the file.
- **2**: check whether the current process has the write permission on the file.
- **4**: check whether the current process has the read permission on the file.| | callback | AsyncCallback<void> | Yes | Callback invoked when the file is asynchronously checked. | -- Example +**Example** ```js fileio.access(path, function (err) { // Do something. @@ -250,13 +257,13 @@ Synchronously checks whether the current process can access the specified file. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ---------------------------------------- | | path | string | Yes | Absolute path of the target file. | | mode | number | No | Options for accessing the file. You can specify multiple options, separated with a bitwise OR operator (|). The default value is **0**.
The options are as follows:
- **0**: check whether the file exists.
- **1**: check whether the current process has the execute permission on the file.
- **2**: check whether the current process has the write permission on the file.
- **4**: check whether the current process has the read permission on the file.| -- Example +**Example** ```js try { fileio.accessSync(path); @@ -270,21 +277,21 @@ Synchronously checks whether the current process can access the specified file. close(fd: number):Promise<void> -Asynchronously closes a file. This method uses a promise to return the result. +Asynchronously closes a file. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ------------ | | fd | number | Yes | File descriptor of the file to close.| -- Return value +**Return value** | Type | Description | | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result. An empty value is returned.| -- Example +**Example** ```js let fd = fileio.openSync(path); fileio.close(fd).then(function(){ @@ -299,17 +306,17 @@ Asynchronously closes a file. This method uses a promise to return the result. close(fd: number, callback:AsyncCallback<void>): void -Asynchronously closes a file. This method uses a callback to return the result. +Asynchronously closes a file. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ------------------------- | ---- | ------------ | | fd | number | Yes | File descriptor of the file to close.| | callback | AsyncCallback<void> | Yes | Callback invoked when the file is closed asynchronously.| -- Example +**Example** ```js let fd = fileio.openSync(path); fileio.close(fd, function (err) { @@ -326,12 +333,12 @@ Synchronously closes a file. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ------------ | | fd | number | Yes | File descriptor of the file to close.| -- Example +**Example** ```js fileio.closeSync(fd); ``` @@ -341,16 +348,16 @@ Synchronously closes a file. close(): Promise<void> -Asynchronously closes the stream. This method uses a promise to return the result. +Asynchronously closes the stream. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Return value +**Return value** | Type | Description | | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result. An empty value is returned.| -- Example +**Example** ```js fileio.close().then(function(){ console.info("close file stream successfully"); @@ -364,16 +371,16 @@ Asynchronously closes the stream. This method uses a promise to return the resul close(callback: AsyncCallback<void>): void -Asynchronously closes the stream. This method uses a callback to return the result. +Asynchronously closes the stream. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ------------------------- | ---- | ------------- | | callback | AsyncCallback<void> | Yes | Callback invoked when the stream is closed asynchronously.| -- Example +**Example** ```js fileio.close(function(err){ // Do something. @@ -385,23 +392,23 @@ Asynchronously closes the stream. This method uses a callback to return the resu copyFile(src:string | number, dest:string | number, mode?:number):Promise<void> -Asynchronously copies a file. This method uses a promise to return the result. +Asynchronously copies a file. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | -------------------------- | ---- | ---------------------------------------- | | src | string \| number | Yes | Path or file descriptor of the file to copy. | | dest | string \| number | Yes | Path or file descriptor of the new file. | | mode | number | No | Option for overwriting the file of the same name in the destination path. The default value is **0**, which is the only value supported.
**0**: Completely overwrite the file with the same name and truncate the part that is not overwritten.| -- Return value +**Return value** | Type | Description | | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result. An empty value is returned.| -- Example +**Example** ```js fileio.copyFile(src, dest).then(function(){ console.info("copyFile successfully"); @@ -415,11 +422,11 @@ Asynchronously copies a file. This method uses a promise to return the result. copyFile(src: string | number, dest: string | number, mode: number, callback: AsyncCallback<void>): void -Asynchronously copies a file. This method uses a callback to return the result. +Asynchronously copies a file. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | -------------------------- | ---- | ---------------------------------------- | | src | string \| number | Yes | Path or file descriptor of the file to copy. | @@ -427,7 +434,7 @@ Asynchronously copies a file. This method uses a callback to return the result. | mode | number | No | Option for overwriting the file of the same name in the destination path. The default value is **0**, which is the only value supported.
**0**: Completely overwrite the file with the same name and truncate the part that is not overwritten.| | callback | AsyncCallback<void> | Yes | Callback invoked when the file is copied asynchronously. | -- Example +**Example** ```js fileio.copyFile(src, dest, function (err) { // Do something. @@ -443,14 +450,14 @@ Synchronously copies a file. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | -------------------------- | ---- | ---------------------------------------- | | src | string \| number | Yes | Path or file descriptor of the file to copy. | | dest | string \| number | Yes | Path or file descriptor of the new file. | | mode | number | No | Option for overwriting the file of the same name in the destination path. The default value is **0**, which is the only value supported.
**0**: Completely overwrite the file with the same name and truncate the part that is not overwritten.| -- Example +**Example** ```js fileio.copyFileSync(src, dest); ``` @@ -460,22 +467,22 @@ Synchronously copies a file. mkdir(path:string, mode?: number): Promise<void> -Asynchronously creates a directory. This method uses a promise to return the result. +Asynchronously creates a directory. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ---------------------------------------- | | path | string | Yes | Absolute path of the directory to create. | | mode | number | No | Permission on the directory to create. You can specify multiple permissions, separated using a bitwise OR operator (|). The default value is **0o775**.
- **0o775**: The owner has the read, write, and execute permissions, and other users have the read and execute permissions.
- **0o700**: The owner has the read, write, and execute permissions.
-  **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.| -- Return value +**Return value** | Type | Description | | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result. An empty value is returned.| -- Example +**Example** ```js fileio.mkdir(path).then(function() { console.info("mkdir successfully"); @@ -489,18 +496,18 @@ Asynchronously creates a directory. This method uses a promise to return the res mkdir(path: string, mode: number, callback: AsyncCallback<void>): void -Asynchronously creates a directory. This method uses a callback to return the result. +Asynchronously creates a directory. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ------------------------- | ---- | ---------------------------------------- | | path | string | Yes | Absolute path of the directory to create. | | mode | number | No | Permission on the directory to create. You can specify multiple permissions, separated using a bitwise OR operator (|). The default value is **0o775**.
- **0o775**: The owner has the read, write, and execute permissions, and other users have the read and execute permissions.
- **0o700**: The owner has the read, write, and execute permissions.
-  **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.| | callback | AsyncCallback<void> | Yes | Callback invoked when the directory is created asynchronously. | -- Example +**Example** ```js fileio.mkdir(path, function(err) { console.info("mkdir successfully"); @@ -516,13 +523,13 @@ Synchronously creates a directory. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ---------------------------------------- | | path | string | Yes | Absolute path of the directory to create. | | mode | number | No | Permission on the directory to create. You can specify multiple permissions, separated using a bitwise OR operator (|). The default value is **0o775**.
- **0o775**: The owner has the read, write, and execute permissions, and other users have the read and execute permissions.
- **0o700**: The owner has the read, write, and execute permissions.
-  **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.| -- Example +**Example** ```js fileio.mkdirSync(path); ``` @@ -532,23 +539,23 @@ Synchronously creates a directory. open(path: string, flags?: number, mode?: number): Promise<number> -Asynchronously opens a file. This method uses a promise to return the result. +Asynchronously opens a file. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ----- | ------ | ---- | ---------------------------------------- | | path | string | Yes | Absolute path of the target file. | - | flags | number | No | Option for opening the file. You must specify one of the following options. By default, the file is open in read-only mode.
- **0o0**: Open the file in read-only mode.
- **0o1**: Open the file in write-only mode.
- **0o2**: Open the file in read/write mode.
In addition, you can specify the following options, separated using a bitwise OR operator (|). By default, no additional option is specified.
- **0o100**: If the file does not exist, create it. If you use this option, you must also specify **mode**.
- **0o200**: If **0o100** is added and the file already exists, throw an exception.
- **0o1000**: If the file exists and is open in write-only or read/write mode, truncate the file length to 0.
- **0o2000**: Open the file in append mode. New data will be appended to the file (added to the end of the file).
- **0o4000**: If **path** points to a named pipe (also known as a FIFO), block special file, or character special file, perform non-blocking operations on the open file and in subsequent I/Os.
- **0o200000**: If **path** points to a directory, throw an exception.

- **0o400000**: If **path** points to a symbolic link, throw an exception.
- **0o4010000**: Open the file in synchronous I/O mode.| + | flags | number | No | Option for opening the file. You must specify one of the following options. By default, the file is open in read-only mode.
- **0o0**: Open the file in read-only mode.
- **0o1**: Open the file in write-only mode.
- **0o2**: Open the file in read/write mode.
In addition, you can specify the following options, separated using a bitwise OR operator (|). By default, no additional option is specified.
- **0o100**: If the file does not exist, create it. If you use this option, you must also specify **mode**.
- **0o200**: If **0o100** is added and the file already exists, throw an exception.
- **0o1000**: If the file exists and is open in write-only or read/write mode, truncate the file length to 0.
- **0o2000**: Open the file in append mode. New data will be appended to the file (added to the end of the file).
- **0o4000**: If **path** points to a named pipe (also known as a FIFO), block special file, or character special file, perform non-blocking operations on the open file and in subsequent I/Os.
- **0o200000**: If **path** points to a directory, throw an exception.

- **0o400000**: If **path** points to a symbolic link, throw an exception.
- **0o4010000**: Open the file in synchronous I/O mode.| | mode | number | No | Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|). The default value is **0o666**.
- **0o666**: The owner, user group, and other users have the read and write permissions on the file.
- **0o700**: The owner has the read, write, and execute permissions.
-  **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.| -- Return value +**Return value** | Type | Description | | --------------------- | ----------- | | Promise<number> | File descriptor of the file opened.| -- Example +**Example** ```js fileio.open(path, 0o1, 0o0200).then(function(number){ console.info("open file successfully"); @@ -562,11 +569,11 @@ Asynchronously opens a file. This method uses a promise to return the result. open(path: string, flags: number, mode: number, callback: AsyncCallback<number>): void -Asynchronously opens a file. This method uses a callback to return the result. +Asynchronously opens a file. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ------------------------------- | ---- | ---------------------------------------- | | path | string | Yes | Absolute path of the target file. | @@ -574,7 +581,7 @@ Asynchronously opens a file. This method uses a callback to return the result. | mode | number | Yes | Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|). The default value is **0o666**.
- **0o666**: The owner, user group, and other users have the read and write permissions on the file.
- **0o700**: The owner has the read, write, and execute permissions.
-  **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.| | callback | AsyncCallback <void> | Yes | Callback invoked when the file is open asynchronously. | -- Example +**Example** ```js fileio.open(path, 0, function(err, fd) { // Do something. @@ -590,19 +597,19 @@ Synchronously opens a file. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ----- | ------ | ---- | ---------------------------------------- | | path | string | Yes | Absolute path of the target file. | | flags | number | No | Option for opening the file. You must specify one of the following options. By default, the file is open in read-only mode.
- **0o0**: Open the file in read-only mode.
- **0o1**: Open the file in write-only mode.
- **0o2**: Open the file in read/write mode.
In addition, you can specify the following options, separated using a bitwise OR operator (|). By default, no additional option is specified.
- **0o100**: If the file does not exist, create it. If you use this option, you must also specify **mode**.
- **0o200**: If **0o100** is added and the file already exists, throw an exception.
- **0o1000**: If the file exists and is open in write-only or read/write mode, truncate the file length to 0.
- **0o2000**: Open the file in append mode. New data will be appended to the file (added to the end of the file).
- **0o4000**: If **path** points to a named pipe (also known as a FIFO), block special file, or character special file, perform non-blocking operations on the open file and in subsequent I/Os.
- **0o200000**: If **path** points to a directory, throw an exception.

- **0o400000**: If **path** points to a symbolic link, throw an exception.
- **0o4010000**: Open the file in synchronous I/O mode.| | mode | number | No | Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|). The default value is **0o666**.
- **0o666**: The owner, user group, and other users have the read and write permissions on the file.
- **0o700**: The owner has the read, write, and execute permissions.
-  **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.
The file permissions on newly created files are affected by umask, which is set as the process starts. Currently, the modification of umask is not open.| -- Return value +**Return value** | Type | Description | | ------ | ----------- | | number | File descriptor of the file opened.| -- Example +**Example** ```js let fd = fileio.openSync(path); ``` @@ -616,23 +623,24 @@ read(fd: number, buffer: ArrayBuffer, options?: { position?: number; }): Promise<ReadOut> -Asynchronously reads data from a file. This method uses a promise to return the result. +Asynchronously reads data from a file. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters - | Name | Type | Mandatory | Description | - | ------- | ----------- | ---- | ---------------------------------------- | - | fd | number | Yes | File descriptor of the file to read. | - | buffer | ArrayBuffer | Yes | Buffer used to store the file data read. | - | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to read in the file. By default, data is read from the current position.
-  The sum of **offset** and **length** must be less than or equal to the buffer size. | +**Parameters** +| Name | Type | Mandatory| Description | +| ------- | ----------- | ---- | ------------------------------------------------------------ | +| fd | number | Yes | File descriptor of the file to read. | +| buffer | ArrayBuffer | Yes | Buffer used to store the file data read. | +| options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to read in the file. By default, data is read from the current position.
Constraints: offset + length <= Buffer size| + +**Return value** -- Return value | Type | Description | | ---------------------------------- | ------ | | Promise<[ReadOut](#readout)> | Data read.| -- Example +**Example** ```js let fd = fileio.openSync(path, 0o2); let buf = new ArrayBuffer(4096); @@ -653,19 +661,19 @@ read(fd: number, buffer: ArrayBuffer, options: { position?: number; }, callback: AsyncCallback<ReadOut>): void -Asynchronously reads data from a file. This method uses a callback to return the result. +Asynchronously reads data from a file. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ---------------------------------------- | | fd | number | Yes | File descriptor of the file to read. | | buffer | ArrayBuffer | Yes | Buffer used to store the file data read. | - | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to read in the file. By default, data is read from the current position.
-  The sum of **offset** and **length** must be less than or equal to the buffer size. | + | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to read in the file. By default, data is read from the current position.
Constraints: offset + length <= Buffer size | | callback | AsyncCallback<[ReadOut](#readout)> | Yes | Callback invoked when the data is read asynchronously. | -- Example +**Example** ```js let fd = fileio.openSync(path, 0o2); let buf = new ArrayBuffer(4096); @@ -690,19 +698,19 @@ Synchronously reads data from a file. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ------- | ----------- | ---- | ---------------------------------------- | | fd | number | Yes | File descriptor of the file to read. | | buffer | ArrayBuffer | Yes | Buffer used to store the file data read. | - | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to read in the file. By default, data is read from the current position.
-  The sum of **offset** and **length** must be less than or equal to the buffer size. | + | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to read in the file. By default, data is read from the current position.
Constraints: offset + length <= Buffer size | -- Return value +**Return value** | Type | Description | | ------ | -------- | | number | Length of the data read.| -- Example +**Example** ```js let fd = fileio.openSync(path, 0o2); let buf = new ArrayBuffer(4096); @@ -714,21 +722,21 @@ Synchronously reads data from a file. rmdir(path: string): Promise<void> -Asynchronously deletes a directory. This method uses a promise to return the result. +Asynchronously deletes a directory. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ----------- | | path | string | Yes | Absolute path of the directory to delete.| -- Return value +**Return value** | Type | Description | | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result. An empty value is returned.| -- Example +**Example** ```js fileio.rmdir(path).then(function() { console.info("rmdir successfully"); @@ -742,17 +750,17 @@ Asynchronously deletes a directory. This method uses a promise to return the res rmdir(path: string, callback:AsyncCallback<void>): void -Asynchronously deletes a directory. This method uses a callback to return the result. +Asynchronously deletes a directory. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ------------------------- | ---- | ------------ | | path | string | Yes | Absolute path of the directory to delete. | | callback | AsyncCallback<void> | Yes | Callback invoked when the directory is deleted asynchronously.| -- Example +**Example** ```js fileio.rmdir(path, function(err){ // Do something. @@ -769,12 +777,12 @@ Synchronously deletes a directory. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ----------- | | path | string | Yes | Absolute path of the directory to delete.| -- Example +**Example** ```js fileio.rmdirSync(path); ``` @@ -784,21 +792,21 @@ Synchronously deletes a directory. unlink(path:string): Promise<void> -Asynchronously deletes a file. This method uses a promise to return the result. +Asynchronously deletes a file. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ----------- | | path | string | Yes | Absolute path of the file to delete.| -- Return value +**Return value** | Type | Description | | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result. An empty value is returned.| -- Example +**Example** ```js fileio.unlink(path).then(function(){ console.info("remove file successfully"); @@ -812,17 +820,17 @@ Asynchronously deletes a file. This method uses a promise to return the result. unlink(path:string, callback:AsyncCallback<void>): void -Asynchronously deletes a file. This method uses a callback to return the result. +Asynchronously deletes a file. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ------------------------- | ---- | ------------ | | path | string | Yes | Absolute path of the file to delete. | | callback | AsyncCallback<void> | Yes | Callback invoked when the file is deleted asynchronously.| -- Example +**Example** ```js fileio.unlink(path, function(err) { console.info("remove file successfully"); @@ -838,12 +846,12 @@ Synchronously deletes a file. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ----------- | | path | string | Yes | Absolute path of the file to delete.| -- Example +**Example** ```js fileio.unlinkSync(path); ``` @@ -858,23 +866,23 @@ write(fd: number, buffer: ArrayBuffer | string, options?: { encoding?: string; }): Promise<number> -Asynchronously writes data into a file. This method uses a promise to return the result. +Asynchronously writes data into a file. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ------- | ------------------------------- | ---- | ---------------------------------------- | | fd | number | Yes | File descriptor of the file to write. | | buffer | ArrayBuffer \| string | Yes | Data to write. It can be a string or data from a buffer. | - | options | Object | No | The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.
-  The sum of **offset** and **length** must be less than or equal to the buffer size.| + | options | Object | No | The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.
Constraints: offset + length <= Buffer size| -- Return value +**Return value** | Type | Description | | --------------------- | -------- | | Promise<number> | Length of the data written in the file.| -- Example +**Example** ```js let fd = fileio.openSync(fpath, 0o100 | 0o2, 0o666); fileio.write(fd, "hello, world").then(function(number){ @@ -894,19 +902,19 @@ write(fd: number, buffer: ArrayBuffer | string, options: { encoding?: string; }, callback: AsyncCallback<number>): void -Asynchronously writes data into a file. This method uses a callback to return the result. +Asynchronously writes data into a file. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ------------------------------- | ---- | ---------------------------------------- | | fd | number | Yes | File descriptor of the file to write. | | buffer | ArrayBuffer \| string | Yes | Data to write. It can be a string or data from a buffer. | - | options | Object | No | The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.
-  The sum of **offset** and **length** must be less than or equal to the buffer size.| + | options | Object | No | The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.
Constraints: offset + length <= Buffer size| | callback | AsyncCallback<number> | Yes | Callback invoked when the data is written asynchronously. | -- Example +**Example** ```js let fd = fileio.openSync(path, 0o100 | 0o2, 0o666); fileio.write(fd, "hello, world", function (err, bytesWritten) { @@ -930,19 +938,19 @@ Synchronously writes data into a file. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ------- | ------------------------------- | ---- | ---------------------------------------- | | fd | number | Yes | File descriptor of the file to write. | | buffer | ArrayBuffer \| string | Yes | Data to write. It can be a string or data from a buffer. | - | options | Object | No | The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.
-  The sum of **offset** and **length** must be less than or equal to the buffer size.| + | options | Object | No | The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.
Constraints: offset + length <= Buffer size| -- Return value +**Return value** | Type | Description | | ------ | -------- | | number | Length of the data written in the file.| -- Example +**Example** ```js let fd = fileio.openSync(path, 0o100 | 0o2, 0o666); let num = fileio.writeSync(fd, "hello, world"); @@ -953,22 +961,22 @@ Synchronously writes data into a file. hash(path: string, algorithm: string): Promise<string> -Asynchronously calculates the hash value of a file. This method uses a promise to return the result. +Asynchronously calculates the hash value of a file. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | --------- | ------ | ---- | ---------------------------------------- | | path | string | Yes | Absolute path of the target file. | - | algorithm | string | Yes | Algorithm used to calculate the hash value. The value can be **md5**, **sha1**, or **sha256**.
**sha256** is recommended for security purposes.| + | algorithm | string | Yes | Algorithm used to calculate the hash value. The value can be **md5**, **sha1**, or **sha256**. **sha256** is recommended for security purposes.| -- Return value +**Return value** | Type | Description | | --------------------- | -------------------------- | | Promise<string> | Promise used to return the hash value of the file. The hash value is a hexadecimal string consisting of digits and uppercase letters.| -- Example +**Example** ```js fileio.hash(path, "sha256").then(function(str){ console.info("calculate file hash successfully:"+ str); @@ -982,18 +990,18 @@ Asynchronously calculates the hash value of a file. This method uses a promise t hash(path: string, algorithm: string, callback: AsyncCallback<string>): void -Asynchronously calculates the hash value of a file. This method uses a callback to return the result. +Asynchronously calculates the hash value of a file. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | --------- | --------------------------- | ---- | ---------------------------------------- | | path | string | Yes | Absolute path of the target file. | - | algorithm | string | Yes | Algorithm used to calculate the hash value. The value can be **md5**, **sha1**, or **sha256**.
**sha256** is recommended for security purposes.| + | algorithm | string | Yes | Algorithm used to calculate the hash value. The value can be **md5**, **sha1**, or **sha256**. **sha256** is recommended for security purposes.| | callback | AsyncCallback<string> | Yes | Callback used to return the hash value. The hash value is a hexadecimal string consisting of digits and uppercase letters.| -- Example +**Example** ```js fileio.hash(fpath, "sha256", function(err, hashStr) { if (hashStr) { @@ -1007,22 +1015,22 @@ Asynchronously calculates the hash value of a file. This method uses a callback chmod(path: string, mode: number):Promise<void> -Asynchronously changes the file permissions based on its path. This method uses a promise to return the result. +Asynchronously changes the file permissions based on its path. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ---------------------------------------- | | path | string | Yes | Absolute path of the target file. | | mode | number | Yes | Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|).
- **0o700**: The owner has the read, write, and execute permissions.
-  **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.| -- Return value +**Return value** | Type | Description | | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result. An empty value is returned.| -- Example +**Example** ```js fileio.chmod(path, mode).then(function() { console.info("chmod successfully"); @@ -1036,18 +1044,18 @@ Asynchronously changes the file permissions based on its path. This method uses chmod(path: string, mode: number, callback: AsyncCallback<void>): void -Asynchronously changes the file permissions based on its path. This method uses a callback to return the result. +Asynchronously changes the file permissions based on its path. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ------------------------- | ---- | ---------------------------------------- | | path | string | Yes | Absolute path of the target file. | | mode | number | Yes | Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|).
- **0o700**: The owner has the read, write, and execute permissions.
-  **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.| | callback | AsyncCallback<void> | Yes | Callback invoked when the file permissions are changed asynchronously. | -- Example +**Example** ```js fileio.chmod(path, mode, function (err) { // Do something. @@ -1063,13 +1071,13 @@ Synchronously changes the file permissions based on its path. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ---------------------------------------- | | path | string | Yes | Absolute path of the target file. | | mode | number | Yes | Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|).
- **0o700**: The owner has the read, write, and execute permissions.
-  **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.| -- Example +**Example** ```js fileio.chmodSync(fpath, mode); ``` @@ -1079,21 +1087,21 @@ Synchronously changes the file permissions based on its path. fstat(fd: number): Promise<Stat> -Asynchronously obtains file status information based on the file descriptor. This method uses a promise to return the result. +Asynchronously obtains file status information based on the file descriptor. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ------------ | | fd | number | Yes | File descriptor of the target file.| -- Return value +**Return value** | Type | Description | | ---------------------------- | ---------- | | Promise<[Stat](#stat)> | Promise used to return the file status information obtained.| -- Example +**Example** ```js fileio.fstat(fd).then(function(stat){ console.info("fstat successfully:"+ JSON.stringify(stat)); @@ -1107,17 +1115,17 @@ Asynchronously obtains file status information based on the file descriptor. Thi fstat(fd: number, callback: AsyncCallback<Stat>): void -Asynchronously obtains file status information based on the file descriptor. This method uses a callback to return the result. +Asynchronously obtains file status information based on the file descriptor. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ---------------------------------- | ---- | ---------------- | | fd | number | Yes | File descriptor of the target file. | | callback | AsyncCallback<[Stat](#stat)> | Yes | Callback invoked when the file status information is obtained asynchronously.| -- Example +**Example** ```js let fd = fileio.openSync(path); fileio.fstat(fd, function (err) { @@ -1134,17 +1142,17 @@ Synchronously obtains file status information based on the file descriptor. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ------------ | | fd | number | Yes | File descriptor of the target file.| -- Return value +**Return value** | Type | Description | | ------------- | ---------- | - | [Stat](#stat) | File status information obtained.| + | [Stat](#stat) | File information obtained.| -- Example +**Example** ```js let fd = fileio.openSync(path); let stat = fileio.fstatSync(fd); @@ -1155,22 +1163,22 @@ Synchronously obtains file status information based on the file descriptor. ftruncate(fd: number, len?: number): Promise<void> -Asynchronously truncates a file based on the file descriptor. This method uses a promise to return the result. +Asynchronously truncates a file based on the file descriptor. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ---------------- | | fd | number | Yes | File descriptor of the file to truncate. | | len | number | Yes | File length, in bytes, after truncation.| -- Return value +**Return value** | Type | Description | | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result. An empty value is returned.| -- Example +**Example** ```js let fd = fileio.openSync(path); fileio.ftruncate(fd, 5).then(function(err) { @@ -1185,18 +1193,18 @@ Asynchronously truncates a file based on the file descriptor. This method uses a ftruncate(fd: number, len: number, callback:AsyncCallback<void>): void -Asynchronously truncates a file based on the file descriptor. This method uses a callback to return the result. +Asynchronously truncates a file based on the file descriptor. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ------------------------- | ---- | ---------------- | | fd | number | Yes | File descriptor of the file to truncate. | | len | number | Yes | File length, in bytes, after truncation.| | callback | AsyncCallback<void> | Yes | Callback invoked when the file is truncated asynchronously. | -- Example +**Example** ```js fileio.ftruncate(fd, len, function(err){ // Do something. @@ -1212,13 +1220,13 @@ Synchronously truncates a file based on the file descriptor. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ---------------- | | fd | number | Yes | File descriptor of the file to truncate. | | len | number | No | File length, in bytes, after truncation.| -- Example +**Example** ```js fileio.ftruncateSync(fd, len); ``` @@ -1228,22 +1236,22 @@ Synchronously truncates a file based on the file descriptor. truncate(path: string, len?: number): Promise<void> -Asynchronously truncates a file based on its path. This method uses a promise to return the result. +Asynchronously truncates a file based on its path. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ---------------- | | path | string | Yes | Absolute path of the file to truncate. | | len | number | Yes | File length, in bytes, after truncation.| -- Return value +**Return value** | Type | Description | | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result. An empty value is returned.| -- Example +**Example** ```js fileio.truncate(path, len).then(function(){ console.info("File truncated successfully."); @@ -1257,18 +1265,18 @@ Asynchronously truncates a file based on its path. This method uses a promise to truncate(path: string, len: number, callback:AsyncCallback<void>): void -Asynchronously truncates a file based on its path. This method uses a callback to return the result. +Asynchronously truncates a file based on its path. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ------------------------- | ---- | ---------------- | | path | string | Yes | Absolute path of the file to truncate. | | len | number | Yes | File length, in bytes, after truncation.| | callback | AsyncCallback<void> | Yes | Callback invoked when the file is truncated asynchronously. | -- Example +**Example** ```js fileio.truncate(path, len, function(err){ // Do something. @@ -1284,13 +1292,13 @@ Synchronously truncates a file based on the file path. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ---------------- | | path | string | Yes | Absolute path of the file to truncate. | | len | number | No | File length, in bytes, after truncation.| -- Example +**Example** ```js fileio.truncateSync(path, len); ``` @@ -1304,22 +1312,22 @@ readText(filePath: string, options?: { encoding?: string; }): Promise<string> -Asynchronously reads the text of a file. This method uses a promise to return the result. +Asynchronously reads the text of a file. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ------ | ---- | ---------------------------------------- | | filePath | string | Yes | Absolute path of the file to read. | | options | Object | No | The options are as follows:
- **position** (number): position of the data to read in the file. By default, data is read from the current position.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **encoding** (string): format of the data (string) to be encoded. The default value is **utf-8**, which is the only value supported.| -- Return value +**Return value** | Type | Description | | --------------------- | ---------- | | Promise<string> | Promise used to return the content of the file read.| -- Example +**Example** ```js fileio.readText(path).then(function(str) { console.info("readText successfully:"+ str); @@ -1337,18 +1345,18 @@ readText(filePath: string, options: { encoding?: string; }, callback: AsyncCallback<string>): void -Asynchronously reads the text of a file. This method uses a callback to return the result. +Asynchronously reads the text of a file. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | --------------------------- | ---- | ---------------------------------------- | | filePath | string | Yes | Absolute path of the file to read. | | options | Object | No | The options are as follows:
- **position** (number): position of the data to read in the file. By default, data is read from the current position.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **encoding** (string): format of the data (string) to be encoded. The default value is **utf-8**, which is the only value supported.| | callback | AsyncCallback<string> | Yes | Callback invoked when the file is read asynchronously. | -- Example +**Example** ```js fileio.readText(path, function(err, str){ // Do something. @@ -1368,18 +1376,18 @@ Synchronously reads the text of a file. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ------ | ---- | ---------------------------------------- | | filePath | string | Yes | Absolute path of the file to read. | | options | Object | No | The options are as follows:
- **position** (number): position of the data to read in the file. By default, data is read from the current position.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **encoding** (string): format of the data (string) to be encoded. The default value is **utf-8**, which is the only value supported.| -- Return value +**Return value** | Type | Description | | ------ | -------------------- | - | string | Content of the file read.| + | string | Promise used to return the content of the file read.| -- Example +**Example** ```js let str = fileio.readTextSync(path, {position: 1, length: 3}); ``` @@ -1389,21 +1397,21 @@ Synchronously reads the text of a file. lstat(path: string): Promise<Stat> -Asynchronously obtains link status information. This method uses a promise to return the result. +Asynchronously obtains link status information. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ----------------- | | path | string | Yes | Absolute path of the target file, pointing to the link status.| -- Return value +**Return value** | Type | Description | | ---------------------------- | ---------- | | Promise<[Stat](#stat)> | Promise used to return the link status obtained.| -- Example +**Example** ```js fileio.lstat(path).then(function(stat){ console.info("Link status obtained:"+ number); @@ -1417,17 +1425,17 @@ Asynchronously obtains link status information. This method uses a promise to re lstat(path:string, callback:AsyncCallback<Stat>): void -Asynchronously obtains link status information. This method uses a callback to return the result. +Asynchronously obtains link status information. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ---------------------------------- | ---- | ----------------- | | path | string | Yes | Absolute path of the target file, pointing to the link status.| | callback | AsyncCallback<[Stat](#stat)> | Yes | Callback invoked when the link status information is obtained asynchronously. | -- Example +**Example** ```js fileio.lstat(path, function (err, stat) { // Do something. @@ -1443,17 +1451,17 @@ Synchronously obtains link status information. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ----------------- | | path | string | Yes | Absolute path of the target file, pointing to the link status.| -- Return value +**Return value** | Type | Description | | ------------- | ---------- | | [Stat](#stat) | Link status obtained.| -- Example +**Example** ```js let stat = fileio.lstatSync(path); ``` @@ -1467,22 +1475,22 @@ read(buffer: ArrayBuffer, options?: { length?: number; }): Promise<ReadOut> -Asynchronously reads data from a file. This method uses a promise to return the result. +Asynchronously reads data from a file. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory| Description | | ------- | ----------- | ---- | ------------------------------------------------------------ | | buffer | ArrayBuffer | Yes | Buffer used to store the file data read. | - | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
-  The sum of **offset** and **length** must be less than or equal to the buffer size.| + | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
Constraints: offset + length <= Buffer size| -- Return value +**Return value** | Type | Description | | ---------------------------------- | ------ | | Promise<[ReadOut](#readout)> | Data read.| -- Example +**Example** ```js fileio.read(new ArrayBuffer(4096)).then(function(readout){ console.info("read file data successfully"); @@ -1501,18 +1509,18 @@ read(buffer: ArrayBuffer, options: { length?: number; }, callback: AsyncCallback<ReadOut>): void -Asynchronously reads data from a file. This method uses a callback to return the result. +Asynchronously reads data from a file. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ---------------------------------------- | | buffer | ArrayBuffer | Yes | Buffer used to store the file data read. | - | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
-  The sum of **offset** and **length** must be less than or equal to the buffer size.| + | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
Constraints: offset + length <= Buffer size| | callback | AsyncCallback<[ReadOut](#readout)> | Yes | Callback invoked when the data is read asynchronously from the file. | -- Example +**Example** ```js let buf = new ArrayBuffer(4096); fileio.read(buf, function (err, readOut) { @@ -1528,22 +1536,22 @@ Asynchronously reads data from a file. This method uses a callback to return the rename(oldPath: string, newPath: string): Promise<void> -Asynchronously renames a file. This method uses a promise to return the result. +Asynchronously renames a file. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory| Description | | ------- | ------ | ---- | ------------------------ | | oldPath | string | Yes | Absolute path of the file to rename.| | newPath | String | Yes | Absolute path of the file renamed. | -- Return value +**Return value** | Type | Description | | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result. An empty value is returned.| -- Example +**Example** ```js fileio.rename(oldPath, newPath).then(function() { console.info("rename successfully"); @@ -1557,18 +1565,18 @@ Asynchronously renames a file. This method uses a promise to return the result. rename(oldPath: string, newPath: string, callback: AsyncCallback<void>): void -Asynchronously renames a file. This method uses a callback to return the result. +Asynchronously renames a file. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ------------------------- | ---- | ------------- | | oldPath | string | Yes | Absolute path of the file to rename. | | newPath | String | Yes | Absolute path of the file renamed. | | Callback | AsyncCallback<void> | Yes | Callback invoked when the file is asynchronously renamed.| -- Example +**Example** ```js fileio.rename(oldPath, newPath, function(err){ }); @@ -1583,13 +1591,13 @@ Synchronously renames a file. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ------- | ------ | ---- | ------------ | | oldPath | string | Yes | Absolute path of the file to rename.| | newPath | String | Yes | Absolute path of the file renamed. | -- Example +**Example** ```js fileio.renameSync(oldPath, newPath); ``` @@ -1599,21 +1607,21 @@ Synchronously renames a file. fsync(fd: number): Promise<void> -Asynchronously synchronizes a file. This method uses a promise to return the result. +Asynchronously synchronizes a file. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ------------ | | fd | number | Yes | File descriptor of the file to synchronize.| -- Return value +**Return value** | Type | Description | | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result. An empty value is returned.| -- Example +**Example** ```js fileio.fsync(fd).then(function(){ console.info("sync data successfully"); @@ -1627,17 +1635,17 @@ Asynchronously synchronizes a file. This method uses a promise to return the res fsync(fd: number, callback: AsyncCallback<void>): void -Asynchronously synchronizes a file. This method uses a callback to return the result. +Asynchronously synchronizes a file. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ------------------------- | ---- | --------------- | | fd | number | Yes | File descriptor of the file to synchronize. | | Callback | AsyncCallback<void> | Yes | Callback invoked when the file is synchronized in asynchronous mode.| -- Example +**Example** ```js fileio.fsync(fd, function(err){ // Do something. @@ -1653,12 +1661,12 @@ Synchronizes a file in synchronous mode. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ------------ | | fd | number | Yes | File descriptor of the file to synchronize.| -- Example +**Example** ```js fileio.fyncsSync(fd); ``` @@ -1668,21 +1676,21 @@ Synchronizes a file in synchronous mode. fdatasync(fd: number): Promise<void> -Asynchronously synchronizes data in a file. This method uses a promise to return the result. +Asynchronously synchronizes data in a file. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ------------ | | fd | number | Yes | File descriptor of the file to synchronize.| -- Return value +**Return value** | Type | Description | | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result asynchronously. An empty value is returned.| -- Example +**Example** ```js fileio.fdatasync(fd).then(function(err) { console.info("sync data successfully"); @@ -1696,17 +1704,17 @@ Asynchronously synchronizes data in a file. This method uses a promise to return fdatasync(fd: number, callback:AsyncCallback<void>): void -Asynchronously synchronizes data in a file. This method uses a callback to return the result. +Asynchronously synchronizes data in a file. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ------------------------------- | ---- | ----------------- | | fd | number | Yes | File descriptor of the file to synchronize. | | callback | AsyncCallback <void> | Yes | Callback invoked when the file data is synchronized in asynchronous mode.| -- Example +**Example** ```js fileio.fdatasync (fd, function (err) { // Do something. @@ -1722,12 +1730,12 @@ Synchronizes data in a file in synchronous mode. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ------------ | | fd | number | Yes | File descriptor of the file to synchronize.| -- Example +**Example** ```js let stat = fileio.fdatasyncSync(fd); ``` @@ -1737,22 +1745,22 @@ Synchronizes data in a file in synchronous mode. symlink(target: string, srcPath: string): Promise<void> -Asynchronously creates a symbolic link based on a path. This method uses a promise to return the result. +Asynchronously creates a symbolic link based on a path. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ------- | ------ | ---- | ------------ | | target | string | Yes | Absolute path of the symbolic link. | | srcPath | string | Yes | Absolute path of the referenced file or directory contained in the symbolic link.| -- Return value +**Return value** | Type | Description | | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result asynchronously. An empty value is returned.| -- Example +**Example** ```js fileio.symlink(target, srcPath).then(function() { console.info("symlink successfully"); @@ -1766,18 +1774,18 @@ Asynchronously creates a symbolic link based on a path. This method uses a promi symlink(target: string, srcPath: string, callback: AsyncCallback<void>): void -Asynchronously creates a symbolic link based on a path. This method uses a callback to return the result. +Asynchronously creates a symbolic link based on a path. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ------------------------- | ---- | ---------------- | | target | string | Yes | Absolute path of the symbolic link. | | srcPath | string | Yes | Absolute path of the referenced file or directory contained in the symbolic link. | | callback | AsyncCallback<void> | Yes | Callback invoked when the symbolic link is created asynchronously.| -- Example +**Example** ```js fileio.symlink(target, srcPath, function (err) { // Do something. @@ -1793,13 +1801,13 @@ Synchronously creates a symbolic link based on a specified path. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ------- | ------ | ---- | ------------ | | target | string | Yes | Absolute path of the symbolic link. | | srcPath | string | Yes | Absolute path of the referenced file or directory contained in the symbolic link.| -- Example +**Example** ```js fileio.symlinkSync(target, srcPath); ``` @@ -1809,23 +1817,23 @@ Synchronously creates a symbolic link based on a specified path. chown(path: string, uid: number, gid: number): Promise<void> -Asynchronously changes the file owner based on its path. This method uses a promise to return the result. +Asynchronously changes the file owner based on its path. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | --------------- | | path | string | Yes | Absolute path of the target file. | | uid | number | Yes | New user ID (UID). | | gid | number | Yes | New group ID (GID).| -- Return value +**Return value** | Type | Description | | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result asynchronously. An empty value is returned.| -- Example +**Example** ```js let stat = fileio.statSync(path); fileio.chown(path, stat.uid, stat.gid).then(function(){ @@ -1840,11 +1848,11 @@ Asynchronously changes the file owner based on its path. This method uses a prom chown(path: string, uid: number, gid: number, callback: AsyncCallback<void>): void -Asynchronously changes the file owner based on its path. This method uses a callback to return the result. +Asynchronously changes the file owner based on its path. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ------------------------- | ---- | --------------- | | path | string | Yes | Absolute path of the target file. | @@ -1852,7 +1860,7 @@ Asynchronously changes the file owner based on its path. This method uses a call | gid | number | Yes | New GID. | | callback | AsyncCallback<void> | Yes | Callback invoked when the file owner is changed asynchronously.| -- Example +**Example** ```js let stat = fileio.statSync(fpath) fileio.chown(path, stat.uid, stat.gid, function (err){ @@ -1869,14 +1877,14 @@ Synchronously changes the file owner based on its path. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ----------- | | path | string | Yes | Absolute path of the target file.| | uid | number | Yes | New UID. | | gid | number | Yes | New GID. | -- Example +**Example** ```js let stat = fileio.statSync(fpath) fileio.chownSync(path, stat.uid, stat.gid); @@ -1887,21 +1895,21 @@ Synchronously changes the file owner based on its path. mkdtemp(prefix: string): Promise<string> -Asynchronously creates a temporary directory. This method uses a promise to return the result. +Asynchronously creates a temporary directory. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ------ | ------ | ---- | --------------------------- | | prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.| -- Return value +**Return value** | Name | Description | | --------------------- | ---------- | | Promise<string> | Unique path generated.| -- Example +**Example** ```js fileio.mkdtemp(path + "XXXX").then(function(path){ console.info("mkdtemp successfully:"+ path); @@ -1915,17 +1923,17 @@ Asynchronously creates a temporary directory. This method uses a promise to retu mkdtemp(prefix: string, callback: AsyncCallback<string>): void -Asynchronously creates a temporary directory. This method uses a callback to return the result. +Asynchronously creates a temporary directory. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | --------------------------- | ---- | --------------------------- | | prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.| | callback | AsyncCallback<string> | Yes | Callback invoked when a temporary directory is created asynchronously. | -- Example +**Example** ```js fileio.mkdtemp(path + "XXXX", function (err, res) { // Do something. @@ -1941,17 +1949,17 @@ Synchronously creates a temporary directory. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ------ | ------ | ---- | --------------------------- | | prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.| -- Return value +**Return value** | Name | Description | | ------ | ---------- | | string | Unique path generated.| -- Example +**Example** ```js let res = fileio.mkdtempSync(path + "XXXX"); ``` @@ -1961,22 +1969,22 @@ Synchronously creates a temporary directory. fchmod(fd: number, mode: number): Promise<void> -Asynchronously changes the file permissions based on the file descriptor. This method uses a promise to return the result. +Asynchronously changes the file permissions based on the file descriptor. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ---------------------------------------- | | fd | number | Yes | File descriptor of the target file. | | mode | number | Yes | Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|).
- **0o700**: The owner has the read, write, and execute permissions.
-  **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.| -- Return value +**Return value** | Name | Description | | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result asynchronously. An empty value is returned.| -- Example +**Example** ```js fileio.fchmod(fd, mode).then(function() { console.info("chmod successfully"); @@ -1990,18 +1998,18 @@ Asynchronously changes the file permissions based on the file descriptor. This m fchmod(fd: number, mode: number, callback: AsyncCallback<void>): void -Asynchronously changes the file permissions based on the file descriptor. This method uses a callback to return the result. +Asynchronously changes the file permissions based on the file descriptor. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ------------------------------- | ---- | ---------------------------------------- | | fd | number | Yes | File descriptor of the target file. | | mode | number | Yes | Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|).
- **0o700**: The owner has the read, write, and execute permissions.
-  **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.| | callback | AsyncCallback <void> | Yes | Callback invoked when the file permissions are changed asynchronously. | -- Example +**Example** ```js fileio.fchmod(fd, mode, function (err) { // Do something. @@ -2017,13 +2025,13 @@ Synchronously changes the file permissions based on the file descriptor. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ---------------------------------------- | | fd | number | Yes | File descriptor of the target file. | | mode | number | Yes | Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|).
- **0o700**: The owner has the read, write, and execute permissions.
-  **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.| -- Example +**Example** ```js fileio.fchmodSync(fd, mode); ``` @@ -2033,22 +2041,22 @@ Synchronously changes the file permissions based on the file descriptor. createStream(path: string, mode: string): Promise<Stream> -Asynchronously opens a stream based on the file path. This method uses a promise to return the result. +Asynchronously opens a stream based on the file path. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ---------------------------------------- | | path | string | Yes | Absolute path of the target file. | | mode | string | Yes | - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.
- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).
- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).| -- Return value +**Return value** | Type | Description | | --------------------------------- | --------- | | Promise<[Stream](#stream7)> | Promise used to return the result.| -- Example +**Example** ```js fileio.createStream(path, "r+").then(function(stream){ console.info("createStream successfully"); @@ -2062,18 +2070,18 @@ Asynchronously opens a stream based on the file path. This method uses a promise createStream(path: string, mode: string, callback: AsyncCallback<Stream>): void -Asynchronously opens a stream based on the file path. This method uses a callback to return the result. +Asynchronously opens a stream based on the file path. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | --------------------------------------- | ---- | ---------------------------------------- | | path | string | Yes | Absolute path of the target file. | | mode | string | Yes | - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.
- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).
- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).| | callback | AsyncCallback<[Stream](#stream7)> | Yes | Callback invoked when the stream is open asynchronously. | -- Example +**Example** ```js fileio.createStream(path, mode, function(err, stream){ // Do something. @@ -2089,18 +2097,18 @@ Synchronously opens a stream based on the file path. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ---------------------------------------- | | path | string | Yes | Absolute path of the target file. | | mode | string | Yes | - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.
- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).
- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).| -- Return value +**Return value** | Name | Description | | ------------------ | --------- | | [Stream](#stream7) | Stream opened.| -- Example +**Example** ```js let ss = fileio.createStreamSync(path, "r+"); ``` @@ -2110,22 +2118,22 @@ Synchronously opens a stream based on the file path. fdopenStream(fd: number, mode: string): Promise<Stream> -Asynchronously opens a stream based on the file descriptor. This method uses a promise to return the result. +Asynchronously opens a stream based on the file descriptor. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ---------------------------------------- | | fd | number | Yes | File descriptor of the target file. | | mode | string | Yes | - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.
- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).
- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).| -- Return value +**Return value** | Name | Description | | --------------------------------- | --------- | | Promise<[Stream](#stream7)> | Promise used to return the result.| -- Example +**Example** ```js fileio.fdopenStream(fd, mode).then(function(stream){ console.info("openStream successfully"); @@ -2139,18 +2147,18 @@ Asynchronously opens a stream based on the file descriptor. This method uses a p fdopenStream(fd: number, mode: string, callback: AsyncCallback<Stream>): void -Asynchronously opens a stream based on the file descriptor. This method uses a callback to return the result. +Asynchronously opens a stream based on the file descriptor. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ---------------------------------------- | | fd | number | Yes | File descriptor of the target file. | | mode | string | Yes | - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.
- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).
- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).| | callback | AsyncCallback <[Stream](#stream7)> | Yes | Callback invoked when the stream is open asynchronously. | -- Example +**Example** ```js fileio.fdopenStream(fd, mode, function (err, stream) { // Do something. @@ -2166,18 +2174,18 @@ Synchronously opens a stream based on the file descriptor. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ---------------------------------------- | | fd | number | Yes | File descriptor of the target file. | | mode | string | Yes | - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.
- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).
- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).| -- Return value - | Name | Description | +**Return value** + | Type | Description | | ------------------ | --------- | | [Stream](#stream7) | Stream opened.| -- Example +**Example** ```js let ss = fileio.fdopenStreamSync(fd, "r+"); ``` @@ -2187,23 +2195,23 @@ Synchronously opens a stream based on the file descriptor. fchown(fd: number, uid: number, gid: number): Promise<void> -Asynchronously changes the file owner based on the file descriptor. This method uses a promise to return the result. +Asynchronously changes the file owner based on the file descriptor. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ------------ | | fd | number | Yes | File descriptor of the target file.| | uid | number | Yes | New UID. | | gid | number | Yes | New GID. | -- Return value +**Return value** | Type | Description | | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result. An empty value is returned.| -- Example +**Example** ```js let stat = fileio.statSync(path); fileio.fchown(fd, stat.uid, stat.gid).then(function() { @@ -2218,11 +2226,11 @@ Asynchronously changes the file owner based on the file descriptor. This method fchown(fd: number, uid: number, gid: number, callback: AsyncCallback<void>): void -Asynchronously changes the file owner based on the file descriptor. This method uses a callback to return the result. +Asynchronously changes the file owner based on the file descriptor. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ------------------------- | ---- | --------------- | | fd | number | Yes | File descriptor of the target file. | @@ -2230,7 +2238,7 @@ Asynchronously changes the file owner based on the file descriptor. This method | gid | number | Yes | New GID. | | callback | AsyncCallback<void> | Yes | Callback invoked when the file owner is changed asynchronously.| -- Example +**Example** ```js let stat = fileio.statSync(fpath); fileio.fchown(fd, stat.uid, stat.gid, function (err){ @@ -2247,14 +2255,14 @@ Synchronously changes the file owner based on the file descriptor. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ------------ | | fd | number | Yes | File descriptor of the target file.| | uid | number | Yes | New UID. | | gid | number | Yes | New GID. | -- Example +**Example** ```js let stat = fileio.statSync(fpath); fileio.fchownSync(fd, stat.uid, stat.gid); @@ -2269,19 +2277,19 @@ Asynchronously changes the file owner based on the file path, changes the owner **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ----------- | | path | string | Yes | Absolute path of the target file.| | uid | number | Yes | New UID. | | gid | number | Yes | New GID. | -- Return value +**Return value** | Type | Description | | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result. An empty value is returned.| -- Example +**Example** ```js let stat = fileio.statSync(path); fileio.lchown(path, stat.uid, stat.gid).then(function() { @@ -2300,7 +2308,7 @@ Asynchronously changes the file owner based on the file path, changes the owner **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ------------------------- | ---- | --------------- | | path | string | Yes | Absolute path of the target file. | @@ -2308,7 +2316,7 @@ Asynchronously changes the file owner based on the file path, changes the owner | gid | number | Yes | New GID. | | callback | AsyncCallback<void> | Yes | Callback invoked when the file owner is changed asynchronously.| -- Example +**Example** ```js let stat = fileio.statSync(path); fileio.lchown(path, stat.uid, stat.gid, function (err){ @@ -2325,14 +2333,14 @@ Synchronously changes the file owner based on the file path and changes the owne **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | ----------- | | path | string | Yes | Absolute path of the target file.| | uid | number | Yes | New UID. | | gid | number | Yes | New GID. | -- Example +**Example** ```js let stat = fileio.statSync(path); fileio.lchownSync(path, stat.uid, stat.gid); @@ -2343,23 +2351,23 @@ Synchronously changes the file owner based on the file path and changes the owne createWatcher(filename: string, events: number, callback: AsyncCallback<number>): Watcher -Asynchronously listens for the changes of a file or directory. This method uses a callback to return the result. +Asynchronously listens for the changes of a file or directory. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | --------------------------------- | ---- | ---------------------------------------- | | filename | string | Yes | Absolute path of the target file. | | events | Number | Yes | - **1**: The file or directory is renamed.
- **2**: The file or directory is modified.
- **3**: The file or directory is modified and renamed.| | callback | AsyncCallback<number > | Yes | Called each time a change is detected. | -- Return value +**Return value** | Name | Description | | -------------------- | ---------- | | [Watcher](#watcher7) | Instance for listening for a file change event.| -- Example +**Example** ```js fileio.createWatcher(filename, events, function(watcher){ // Do something. @@ -2412,12 +2420,12 @@ Checks whether this file is a block special file. A block special file supports **System capability**: SystemCapability.FileManagement.File.FileIO -- Return value +**Return value** | Type | Description | | ------- | ---------------- | | boolean | Whether the file is a block special file.| -- Example +**Example** ```js let isBLockDevice = fileio.statSync(path).isBlockDevice(); ``` @@ -2431,12 +2439,12 @@ Checks whether this file is a character special file. A character special file s **System capability**: SystemCapability.FileManagement.File.FileIO -- Return value +**Return value** | Type | Description | | ------- | ----------------- | | boolean | Whether the file is a character special file.| -- Example +**Example** ```js let isCharacterDevice = fileio.statSync(path).isCharacterDevice(); ``` @@ -2450,12 +2458,12 @@ Checks whether this file is a directory. **System capability**: SystemCapability.FileManagement.File.FileIO -- Return value +**Return value** | Type | Description | | ------- | ------------- | | boolean | Whether the file is a directory.| -- Example +**Example** ```js let isDirectory = fileio.statSync(path).isDirectory(); ``` @@ -2469,12 +2477,12 @@ Checks whether this file is a named pipe (or FIFO). Named pipes are used for int **System capability**: SystemCapability.FileManagement.File.FileIO -- Return value +**Return value** | Type | Description | | ------- | --------------------- | | boolean | Whether the file is an FIFO.| -- Example +**Example** ```js let isFIFO = fileio.statSync(path).isFIFO(); ``` @@ -2488,12 +2496,12 @@ Checks whether this file is a regular file. **System capability**: SystemCapability.FileManagement.File.FileIO -- Return value +**Return value** | Type | Description | | ------- | --------------- | | boolean | Whether the file is a regular file.| -- Example +**Example** ```js let isFile = fileio.statSync(fpath).isFile(); ``` @@ -2507,12 +2515,12 @@ Checks whether this file is a socket. **System capability**: SystemCapability.FileManagement.File.FileIO -- Return value +**Return value** | Type | Description | | ------- | -------------- | | boolean | Whether the file is a socket.| -- Example +**Example** ```js let isSocket = fileio.statSync(path).isSocket(); ``` @@ -2526,12 +2534,12 @@ Checks whether this file is a symbolic link. **System capability**: SystemCapability.FileManagement.File.FileIO -- Return value +**Return value** | Type | Description | | ------- | --------------- | | boolean | Whether the file is a symbolic link.| -- Example +**Example** ```js let isSymbolicLink = fileio.statSync(path).isSymbolicLink(); ``` @@ -2546,11 +2554,11 @@ Listens for the changes of a file. You can call the **Watcher.stop()** method sy stop(): Promise<void> -Asynchronously stops **watcher**. This method uses a promise to return the result. +Asynchronously stops **watcher**. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Example +**Example** ```js fileio.stop(); ``` @@ -2560,16 +2568,16 @@ Asynchronously stops **watcher**. This method uses a promise to return the resul stop(callback: AsyncCallback<void>): void -Asynchronously stops **watcher**. This method uses a callback to return the result. +Asynchronously stops **watcher**. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ------------------------- | ---- | ---------------------- | | callback | AsyncCallback<void> | Yes | Callback invoked when **watcher** is stopped asynchronously.| -- Example +**Example** ```js fileio.stop(function(err){ // Do something. @@ -2587,16 +2595,16 @@ File stream. Before calling a method of the **Stream** class, use the **createSt close(): Promise<void> -Asynchronously closes the stream. This method uses a promise to return the result. +Asynchronously closes the stream. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Return value +**Return value** | Type | Description | | ------------------- | ------------- | | Promise<void> | Promise used to return the stream close result.| -- Example +**Example** ```js let ss= fileio.createStreamSync(path); ss.close().then(function(){ @@ -2611,16 +2619,16 @@ Asynchronously closes the stream. This method uses a promise to return the resul close(callback: AsyncCallback<void>): void -Asynchronously closes the stream. This method uses a callback to return the result. +Asynchronously closes the stream. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ------------------------- | ---- | ------------- | | callback | AsyncCallback<void> | Yes | Callback invoked when the stream is closed asynchronously.| -- Example +**Example** ```js let ss= fileio.createStreamSync(path); ss.close(function (err) { @@ -2637,7 +2645,7 @@ Synchronously closes the stream. **System capability**: SystemCapability.FileManagement.File.FileIO -- Example +**Example** ```js let ss= fileio.createStreamSync(path); ss.closeSync(); @@ -2648,16 +2656,16 @@ Synchronously closes the stream. flush(): Promise<void> -Asynchronously flushes the stream. This method uses a promise to return the result. +Asynchronously flushes the stream. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Return value +**Return value** | Type | Description | | ------------------- | ------------- | | Promise<void> | Promise used to return the stream flushing result.| -- Example +**Example** ```js let ss= fileio.createStreamSync(path); ss.flush().then(function (){ @@ -2672,16 +2680,16 @@ Asynchronously flushes the stream. This method uses a promise to return the resu flush(callback: AsyncCallback<void>): void -Asynchronously flushes the stream. This method uses a callback to return the result. +Asynchronously flushes the stream. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ------------------------- | ---- | -------------- | | callback | AsyncCallback<void> | Yes | Callback invoked when the stream is asynchronously flushed.| -- Example +**Example** ```js let ss= fileio.createStreamSync(path); ss.flush(function (err) { @@ -2698,7 +2706,7 @@ Synchronously flushes the stream. **System capability**: SystemCapability.FileManagement.File.FileIO -- Example +**Example** ```js let ss= fileio.createStreamSync(path); ss.flushSync(); @@ -2714,22 +2722,22 @@ write(buffer: ArrayBuffer | string, options?: { encoding?: string; }): Promise<number> -Asynchronously writes data into the stream. This method uses a promise to return the result. +Asynchronously writes data into the stream. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ------- | ------------------------------- | ---- | ---------------------------------------- | | buffer | ArrayBuffer \| string | Yes | Data to write. It can be a string or data from a buffer. | - | options | Object | No | The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.
-  The sum of **offset** and **length** must be less than or equal to the buffer size. | + | options | Object | No | The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.
Constraints: offset + length <= Buffer size | -- Return value +**Return value** | Type | Description | | --------------------- | -------- | | Promise<number> | Length of the data written in the file.| -- Example +**Example** ```js let ss= fileio.createStreamSync(fpath, "r+"); ss.write("hello, world",{offset: 1,length: 5,position: 5,encoding :'utf-8'}).then(function (number){ @@ -2749,18 +2757,18 @@ write(buffer: ArrayBuffer | string, options: { encoding?: string; }, callback: AsyncCallback<number>): void -Asynchronously writes data into the stream. This method uses a callback to return the result. +Asynchronously writes data into the stream. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory| Description | | -------- | ------------------------------- | ---- | ------------------------------------------------------------ | | buffer | ArrayBuffer \| string | Yes | Data to write. It can be a string or data from a buffer. | - | options | Object | No | The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.
-  The sum of **offset** and **length** must be less than or equal to the buffer size.| + | options | Object | No | The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.
Constraints: offset + length <= Buffer size| | callback | AsyncCallback<number> | Yes | Callback invoked when the data is written asynchronously. | -- Example +**Example** ```js let ss= fileio.createStreamSync(fpath, "r+"); ss.write("hello, world", {offset: 1, length: 5, position: 5, encoding :'utf-8'}, function (err, bytesWritten) { @@ -2785,18 +2793,18 @@ Synchronously writes data into the stream. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ------- | ------------------------------- | ---- | ---------------------------------------- | | buffer | ArrayBuffer \| string | Yes | Data to write. It can be a string or data from a buffer. | - | options | Object | No | The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.
-  The sum of **offset** and **length** must be less than or equal to the buffer size. | + | options | Object | No | The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.
Constraints: offset + length <= Buffer size | -- Return value +**Return value** | Type | Description | | ------ | -------- | | number | Length of the data written in the file.| -- Example +**Example** ```js let ss= fileio.createStreamSync(fpath,"r+"); let num = ss.writeSync("hello, world", {offset: 1, length: 5, position: 5, encoding :'utf-8'}); @@ -2811,22 +2819,22 @@ read(buffer: ArrayBuffer, options?: { length?: number; }): Promise<ReadOut> -Asynchronously reads data from the stream. This method uses a promise to return the result. +Asynchronously reads data from the stream. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | ------- | ----------- | ---- | ---------------------------------------- | | buffer | ArrayBuffer | Yes | Buffer used to store the file read. | - | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to read in the file. By default, data is read from the current position.
-  The sum of **offset** and **length** must be less than or equal to the buffer size. | + | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to read in the file. By default, data is read from the current position.
Constraints: offset + length <= Buffer size | -- Return value +**Return value** | Type | Description | | ---------------------------------- | ------ | | Promise<[ReadOut](#readout)> | Data read.| -- Example +**Example** ```js let ss = fileio.createStreamSync(fpath, "r+"); ss.read(new ArrayBuffer(4096), {offset: 1, length: 5, position: 5}).then(function (readout){ @@ -2846,18 +2854,18 @@ read(buffer: ArrayBuffer, options: { length?: number; }, callback: AsyncCallback<ReadOut>): void -Asynchronously reads data from the stream. This method uses a callback to return the result. +Asynchronously reads data from the stream. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ---------------------------------------- | | buffer | ArrayBuffer | Yes | Buffer used to store the file read. | - | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to read in the file. By default, data is read from the current position.
-  The sum of **offset** and **length** must be less than or equal to the buffer size. | + | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to read in the file. By default, data is read from the current position.
Constraints: offset + length <= Buffer size | | callback | AsyncCallback<[ReadOut](#readout)> | Yes | Callback invoked when data is read asynchronously from the stream. | -- Example +**Example** ```js let ss = fileio.createStreamSync(fpath, "r+"); ss.read(new ArrayBuffer(4096),{offset: 1, length: 5, position: 5},function (err, readOut) { @@ -2881,18 +2889,20 @@ Synchronously reads data from the stream. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** + | Name | Type | Mandatory | Description | | ------- | ----------- | ---- | ---------------------------------------- | | buffer | ArrayBuffer | Yes | Buffer used to store the file read. | - | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to read in the file. By default, data is read from the current position.
-  The sum of **offset** and **length** must be less than or equal to the buffer size. | + | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to read in the file. By default, data is read from the current position.
Constraints: offset + length <= Buffer size | + +**Return value** -- Return value | Type | Description | | ------ | -------- | | number | Length of the data read.| -- Example +**Example** ```js let ss = fileio.createStreamSync(fpath, "r+"); let num = ss.readSync(new ArrayBuffer(4096), {offset: 1, length: 5, position: 5}); @@ -2908,16 +2918,16 @@ Manages directories. Before calling a method of the **Dir** class, use the [open read(): Promise<Dirent> -Asynchronously reads the next directory entry. This method uses a promise to return the result. +Asynchronously reads the next directory entry. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Return value +**Return value** | Type | Description | | -------------------------------- | ------------- | | Promise<[Dirent](#dirent)> | Directory entry that is read asynchronously.| -- Example +**Example** ```js let dir = fileio.opendirSync(path); dir.read().then(function (dirent){ @@ -2932,16 +2942,16 @@ Asynchronously reads the next directory entry. This method uses a promise to ret read(callback: AsyncCallback<Dirent>): void -Asynchronously reads the next directory entry. This method uses a callback to return the result. +Asynchronously reads the next directory entry. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | -------------------------------------- | ---- | ---------------- | | callback | AsyncCallback<[Dirent](#dirent)> | Yes | Callback invoked when the next directory entry is asynchronously read.| -- Example +**Example** ```js let dir = fileio.opendirSync(path); dir.read(function (err, dirent) { @@ -2961,12 +2971,12 @@ Synchronously reads the next directory entry. **System capability**: SystemCapability.FileManagement.File.FileIO -- Return value +**Return value** | Type | Description | | ----------------- | -------- | | [Dirent](#dirent) | Directory entry read.| -- Example +**Example** ```js let dir = fileio.opendirSync(path); let dirent = dir.readSync(); @@ -2981,7 +2991,7 @@ Closes a directory. After a directory is closed, the file descriptor in Dir will **System capability**: SystemCapability.FileManagement.File.FileIO -- Example +**Example** ```js let dir = fileio.opendirSync(path); dir.closeSync(); @@ -3009,12 +3019,12 @@ Checks whether the current directory entry is a block special file. A block spec **System capability**: SystemCapability.FileManagement.File.FileIO -- Return value +**Return value** | Type | Description | | ------- | ---------------- | | boolean | Whether the directory entry is a block special file.| -- Example +**Example** ```js let dir = fileio.opendirSync(path); let isBLockDevice = dir.readSync().isBlockDevice(); @@ -3029,12 +3039,12 @@ Checks whether a directory entry is a character special file. A character specia **System capability**: SystemCapability.FileManagement.File.FileIO -- Return value +**Return value** | Type | Description | | ------- | ----------------- | | boolean | Whether the directory entry is a character special file.| -- Example +**Example** ```js let dir = fileio.opendirSync(path); let isCharacterDevice = dir.readSync().isCharacterDevice(); @@ -3049,12 +3059,12 @@ Checks whether a directory entry is a directory. **System capability**: SystemCapability.FileManagement.File.FileIO -- Return value +**Return value** | Type | Description | | ------- | ------------- | | boolean | Whether the directory entry is a directory.| -- Example +**Example** ```js let dir = fileio.opendirSync(path); let isDirectory = dir.readSync().isDirectory(); @@ -3069,12 +3079,12 @@ Checks whether the current directory entry is a named pipe (or FIFO). Named pipe **System capability**: SystemCapability.FileManagement.File.FileIO -- Return value +**Return value** | Type | Description | | ------- | --------------- | | boolean | Whether the directory entry is a FIFO.| -- Example +**Example** ```js let dir = fileio.opendirSync(path); let isFIFO = dir.readSync().isFIFO(); @@ -3089,12 +3099,12 @@ Checks whether a directory entry is a regular file. **System capability**: SystemCapability.FileManagement.File.FileIO -- Return value +**Return value** | Type | Description | | ------- | --------------- | | boolean | Whether the directory entry is a regular file.| -- Example +**Example** ```js let dir = fileio.opendirSync(path); let isFile = dir.readSync().isFile(); @@ -3109,12 +3119,12 @@ Checks whether a directory entry is a socket. **System capability**: SystemCapability.FileManagement.File.FileIO -- Return value +**Return value** | Type | Description | | ------- | -------------- | | boolean | Whether the directory entry is a socket.| -- Example +**Example** ```js let dir = fileio.opendirSync(dpath); let isSocket = dir.readSync().isSocket(); @@ -3129,12 +3139,12 @@ Checks whether a directory entry is a symbolic link. **System capability**: SystemCapability.FileManagement.File.FileIO -- Return value +**Return value** | Type | Description | | ------- | --------------- | | boolean | Whether the directory entry is a symbolic link.| -- Example +**Example** ```js let dir = fileio.opendirSync(path); let isSymbolicLink = dir.readSync().isSymbolicLink(); diff --git a/en/application-dev/reference/apis/js-apis-system-storage.md b/en/application-dev/reference/apis/js-apis-system-storage.md index d80bf1ea12d54ac3d2bae32ec81c88cd293dfa62..37e8dc5de76e930a81a337c9afd3fe0adcd459c4 100644 --- a/en/application-dev/reference/apis/js-apis-system-storage.md +++ b/en/application-dev/reference/apis/js-apis-system-storage.md @@ -1,6 +1,6 @@ # Data Storage -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **NOTE**
> > - The APIs of this module are no longer maintained since API Version 6, and you are advised to use [`@ohos.data.storage`](js-apis-data-storage.md). From API Version 9, you are advised to use [`@ohos.data.preferences`](js-apis-data-preferences.md). > @@ -67,7 +67,7 @@ Sets the value in the cache based on the specified key. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| key | string | Yes| Key of the value to set.| +| key | string | Yes| Key of the data to set.| | value | string | Yes| New value to set. The maximum length is 128 bytes.| | success | Function | No| Called when **storage.set()** is successful.| | fail | Function | No| Called when **storage.set()** fails. In the callback, **data** indicates the error information, and **code** indicates the error code.| diff --git a/en/application-dev/reference/apis/js-apis-useriam-userauth.md b/en/application-dev/reference/apis/js-apis-useriam-userauth.md index 02992c0a5f646bd1016cbcdd3aae92aac0c32f2a..39b0daf04ecbf60d2f4cefbeb4b60416c187ed68 100644 --- a/en/application-dev/reference/apis/js-apis-useriam-userauth.md +++ b/en/application-dev/reference/apis/js-apis-useriam-userauth.md @@ -1,6 +1,6 @@ # User Authentication -> ![icon-note.gif](public_sys-resources/icon-note.gif)**NOTE**
+> **NOTE**
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -122,7 +122,7 @@ Obtains an **Authenticator** object for user authentication. **Return value** | Type | Description | | ----------------------------------------- | ------------ | -| [Authenticator](#authenticatordeprecated) | **Authenticator** object obtained.| +| [Authenticator](#authenticatordeprecated) | **Authenticator** object obtained. | **Example** ```js @@ -144,7 +144,7 @@ execute(type: string, level: string, callback: AsyncCallback<number>): voi > **NOTE**
> This API is not longer maintained since API version 8. You are advised to use [auth](#auth8). -Performs user authentication. This method uses asynchronous callback to return the result. +Performs user authentication. This API uses asynchronous callback to return the result. **Required permissions**: ohos.permission.ACCESS_BIOMETRIC @@ -154,15 +154,15 @@ Performs user authentication. This method uses asynchronous callback to return t | Name | Type | Mandatory| Description | | -------- | --------------------------- | ---- | ------------------------------------------------------------ | -| type | string | Yes | Authentication type. Only **FACE_ONLY** is supported.
**ALL** is reserved and not supported by the current version.| -| level | string | Yes | Security level of the authentication. It can be S1 (lowest), S2, S3, or S4 (highest).
Devices capable of 3D facial recognition support S3 and lower-level authentication.
Devices capable of 2D facial recognition support S2 and lower-level authentication.| +| type | string | Yes | Authentication type. Only **FACE_ONLY** is supported.
**ALL** is reserved and not supported by the current version. | +| level | string | Yes | Security level of the authentication. It can be S1 (lowest), S2, S3, or S4 (highest).
Devices capable of 3D facial recognition support S3 and lower-level authentication.
Devices capable of 2D facial recognition support S2 and lower-level authentication. | | callback | AsyncCallback<number> | No | Callback used to return the result. | Parameters returned in callback | Type | Description | | ------ | ------------------------------------------------------------ | -| number | Authentication result. For details, see [AuthenticationResult](#authenticationresultdeprecated).| +| number | Authentication result. For details, see [AuthenticationResult](#authenticationresultdeprecated). | **Example** ```js @@ -183,7 +183,7 @@ execute(type:string, level:string): Promise<number> > **NOTE**
> This API is not longer maintained since API version 8. You are advised to use [auth](#auth8). -Performs user authentication. This method uses a promise to return the result. +Performs user authentication. This API uses a promise to return the result. **Required permissions**: ohos.permission.ACCESS_BIOMETRIC @@ -192,13 +192,13 @@ Performs user authentication. This method uses a promise to return the result. **Parameters** | Name| Type | Mandatory| Description | | ------ | ------ | ---- | ------------------------------------------------------------ | -| type | string | Yes | Authentication type. Only **FACE_ONLY** is supported.
**ALL** is reserved and not supported by the current version.| -| level | string | Yes | Security level of the authentication. It can be S1 (lowest), S2, S3, or S4 (highest).
Devices capable of 3D facial recognition support S3 and lower-level authentication.
Devices capable of 2D facial recognition support S2 and lower-level authentication.| +| type | string | Yes | Authentication type. Only **FACE_ONLY** is supported.
**ALL** is reserved and not supported by the current version. | +| level | string | Yes | Security level of the authentication. It can be S1 (lowest), S2, S3, or S4 (highest).
Devices capable of 3D facial recognition support S3 and lower-level authentication.
Devices capable of 2D facial recognition support S2 and lower-level authentication. | **Return value** | Type | Description | | --------------------- | ------------------------------------------------------------ | -| Promise<number> | Promise used to return the authentication result, which is a number. For details, see [AuthenticationResult](#authenticationresultdeprecated).| +| Promise<number> | Promise used to return the authentication result, which is a number. For details, see [AuthenticationResult](#authenticationresultdeprecated). | **Example** @@ -222,7 +222,7 @@ Enumerates the authentication results. | Name | Default Value| Description | | ------------------ | ------ | -------------------------- | -| NO_SUPPORT | -1 | The device does not support the current authentication mode.| +| NO_SUPPORT | -1 | The device does not support the current authentication mode. | | SUCCESS | 0 | The authentication is successful. | | COMPARE_FAILURE | 1 | The feature comparison failed. | | CANCELED | 2 | The authentication was canceled by the user. | @@ -230,7 +230,7 @@ Enumerates the authentication results. | CAMERA_FAIL | 4 | The camera failed to start. | | BUSY | 5 | The authentication service is not available. Try again later. | | INVALID_PARAMETERS | 6 | The authentication parameters are invalid. | -| LOCKED | 7 | The user account is locked because the number of authentication failures has reached the threshold.| +| LOCKED | 7 | The user account is locked because the number of authentication failures has reached the threshold. | | NOT_ENROLLED | 8 | No authentication credential is registered. | | GENERAL_ERROR | 100 | Other errors. | @@ -252,7 +252,7 @@ A constructor used to create an **authenticator** object. | Type | Description | | ---------------------- | -------------------- | -| [UserAuth](#userauth8) | **Authenticator** object obtained.| +| [UserAuth](#userauth8) | **Authenticator** object obtained. | **Example** @@ -276,7 +276,7 @@ Obtains the authentication executor version. | Type | Description | | ------ | ---------------------- | -| number | Authentication executor version obtained.| +| number | Authentication executor version obtained. | **Example** @@ -302,14 +302,14 @@ Checks whether the authentication capability of the specified trust level is ava | Name | Type | Mandatory| Description | | -------------- | ---------------------------------- | ---- | -------------------------- | -| authType | [UserAuthType](#userauthtype8) | Yes | Authentication type. Only **FACE** is supported.| +| authType | [UserAuthType](#userauthtype8) | Yes | Authentication type. Only **FACE** is supported. | | authTrustLevel | [AuthTrustLevel](#authtrustlevel8) | Yes | Trust level of the authentication result. | **Return value** | Type | Description | | ------ | ------------------------------------------------------------ | -| number | Whether the authentication capability of the specified trust level is available. For details, see [ResultCode](#resultcode8).| +| number | Whether the authentication capability of the specified trust level is available. For details, see [ResultCode](#resultcode8). | **Example** @@ -331,7 +331,7 @@ Checks whether the authentication capability of the specified trust level is ava auth(challenge: Uint8Array, authType: UserAuthType, authTrustLevel: AuthTrustLevel, callback: IUserAuthCallback): Uint8Array -Performs user authentication. This method uses a callback to return the result. +Performs user authentication. This API uses a callback to return the result. **Required permissions**: ohos.permission.ACCESS_BIOMETRIC @@ -342,7 +342,7 @@ Performs user authentication. This method uses a callback to return the result. | Name | Type | Mandatory| Description | | -------------- | ---------------------------------------- | ---- | ------------------------ | | challenge | Uint8Array | Yes | Challenge value, which can be null. | -| authType | [UserAuthType](#userauthtype8) | Yes | Authentication type. Only **FACE** is supported.| +| authType | [UserAuthType](#userauthtype8) | Yes | Authentication type. Only **FACE** is supported. | | authTrustLevel | [AuthTrustLevel](#authtrustlevel8) | Yes | Trust level. | | callback | [IUserAuthCallback](#iuserauthcallback8) | Yes | Callback used to return the result. | @@ -350,7 +350,7 @@ Performs user authentication. This method uses a callback to return the result. | Type | Description | | ---------- | ------------------------------------------------------------ | -| Uint8Array | ContextId, which is used as the input parameter of [cancelAuth](#cancelauth8).| +| Uint8Array | ContextId, which is used as the input parameter of [cancelAuth](#cancelauth8). | **Example** @@ -389,13 +389,13 @@ Cancels an authentication. | Name | Type | Mandatory| Description | | --------- | ---------- | ---- | ------------------------------------------ | -| contextID | Uint8Array | Yes | Context ID, which is obtained using [auth](#auth8).| +| contextID | Uint8Array | Yes | Context ID, which is obtained using [auth](#auth8). | **Return value** | Type | Description | | ------ | ------------------------ | -| number | Whether the authentication is canceled.| +| number | Whether the authentication is canceled. | **Example** @@ -429,7 +429,7 @@ Obtains the authentication result. | Name | Type | Mandatory| Description | | --------- | -------------------------- | ---- | ------------------------------------------------------------ | | result | number | Yes | Authentication result obtained. For details, see [ResultCode](#resultcode8). | -| extraInfo | [AuthResult](#authresult8) | Yes | Extended information, which varies depending on the authentication result.
If the authentication is successful, the user authentication token will be returned in **extraInfo**.
If the authentication fails, the remaining number of authentication times will be returned in **extraInfo**.
If the authentication executor is locked, the freeze time will be returned in **extraInfo**.| +| extraInfo | [AuthResult](#authresult8) | Yes | Extended information, which varies depending on the authentication result.
If the authentication is successful, the user authentication token will be returned in **extraInfo**.
If the authentication fails, the remaining number of authentication times will be returned in **extraInfo**.
If the authentication executor is locked, the freeze time will be returned in **extraInfo**. | **Example** @@ -478,7 +478,7 @@ Obtains the tip code information during authentication. This function is optiona | Name | Type | Mandatory| Description | | --------- | ------ | ---- | ------------------------------ | | module | number | Yes | Type of the authentication executor. | -| acquire | number | Yes | Interaction information of the authentication executor during the authentication process.| +| acquire | number | Yes | Interaction information of the authentication executor during the authentication process. | | extraInfo | any | Yes | Reserved field. | **Example** @@ -523,8 +523,8 @@ Represents the authentication result object. | Name | Type | Mandatory| Description | | ------------ | ---------- | ---- | -------------------- | | token | Uint8Array | No | Identity authentication token. | -| remainTimes | number | No | Number of remaining authentication operations.| -| freezingTime | number | No | Time for which the authentication operation is frozen.| +| remainTimes | number | No | Number of remaining authentication operations. | +| freezingTime | number | No | Time for which the authentication operation is frozen. | ## ResultCode8+ @@ -544,7 +544,7 @@ Enumerates the operation results. | BUSY | 7 | Indicates the busy state. | | INVALID_PARAMETERS | 8 | Invalid parameters are detected. | | LOCKED | 9 | The authentication executor is locked. | -| NOT_ENROLLED | 10 | The user has not entered the authentication information.| +| NOT_ENROLLED | 10 | The user has not entered the authentication information. | ## FaceTips8+ @@ -563,7 +563,7 @@ Enumerates the tip codes used during the facial authentication process. | FACE_AUTH_TIP_TOO_LOW | 6 | Only the lower part of the face is captured because the device is angled too low. | | FACE_AUTH_TIP_TOO_RIGHT | 7 | Only the right part of the face is captured because the device is deviated to the right. | | FACE_AUTH_TIP_TOO_LEFT | 8 | Only the left part of the face is captured because the device is deviated to the left. | -| FACE_AUTH_TIP_TOO_MUCH_MOTION | 9 | The face moves too fast during facial information collection.| +| FACE_AUTH_TIP_TOO_MUCH_MOTION | 9 | The face moves too fast during facial information collection. | | FACE_AUTH_TIP_POOR_GAZE | 10 | The face is not facing the camera. | | FACE_AUTH_TIP_NOT_DETECTED | 11 | No face is detected. | @@ -577,7 +577,7 @@ Enumerates the tip codes used during the fingerprint authentication process. | Name | Default Value| Description | | --------------------------------- | ------ | -------------------------------------------------- | | FINGERPRINT_AUTH_TIP_GOOD | 0 | The obtained fingerprint image is in good condition. | -| FINGERPRINT_AUTH_TIP_DIRTY | 1 | Large fingerprint image noise is detected due to suspicious or detected dirt on the sensor.| +| FINGERPRINT_AUTH_TIP_DIRTY | 1 | Large fingerprint image noise is detected due to suspicious or detected dirt on the sensor. | | FINGERPRINT_AUTH_TIP_INSUFFICIENT | 2 | The noise of the fingerprint image is too large to be processed. | | FINGERPRINT_AUTH_TIP_PARTIAL | 3 | Incomplete fingerprint image is detected. | | FINGERPRINT_AUTH_TIP_TOO_FAST | 4 | The fingerprint image is incomplete due to fast movement. | @@ -592,8 +592,8 @@ Enumerates the identity authentication types. | Name | Default Value| Description | | ----------- | ------ | ---------- | -| FACE | 2 | Facial authentication.| -| FINGERPRINT | 4 | Fingerprint authentication.| +| FACE | 2 | Facial authentication. | +| FINGERPRINT | 4 | Fingerprint authentication. | ## AuthTrustLevel8+ @@ -603,7 +603,7 @@ Enumerates the trust levels of the authentication result. | Name| Default Value| Description | | ---- | ------ | ------------------------- | -| ATL1 | 10000 | Trust level 1.| -| ATL2 | 20000 | Trust level 2.| -| ATL3 | 30000 | Trust level 3.| -| ATL4 | 40000 | Trust level 4.| +| ATL1 | 10000 | Trust level 1. | +| ATL2 | 20000 | Trust level 2. | +| ATL3 | 30000 | Trust level 3. | +| ATL4 | 40000 | Trust level 4. | diff --git a/en/application-dev/reference/apis/js-apis-util.md b/en/application-dev/reference/apis/js-apis-util.md index ecc46e0c2d4b17d6d6a462c312a7860627b579a2..0ee9fb84705d1c23d9c453e75dd47689bc66d1d3 100755 --- a/en/application-dev/reference/apis/js-apis-util.md +++ b/en/application-dev/reference/apis/js-apis-util.md @@ -1,7 +1,7 @@ # util -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> **NOTE**
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -23,15 +23,15 @@ Prints the input content in a formatted string. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| format | string | Yes| Format of the string to print.| -| ...args | Object[] | No| Data to format.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | format | string | Yes | Format of the string to print. | + | ...args | Object[] | No | Data to format. | **Return value** -| Type| Description| -| -------- | -------- | -| string | String in the specified format.| + | Type | Description | + | -------- | -------- | + | string | String in the specified format. | **Example** ```js @@ -49,14 +49,14 @@ Obtains detailed information about a system error code. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| errno | number | Yes| Error code generated.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | errno | number | Yes | Error code generated. | **Return value** -| Type| Description| -| -------- | -------- | -| string | Detailed information about the error code.| + | Type | Description | + | -------- | -------- | + | string | Detailed information about the error code. | **Example** ```js @@ -76,14 +76,14 @@ Calls back an asynchronous function. In the callback, the first parameter indica **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| original | Function | Yes| Asynchronous function.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | original | Function | Yes | Asynchronous function. | **Return value** -| Type| Description| -| -------- | -------- | -| Function | Callback, in which the first parameter indicates the cause of the rejection (the value is **null** if the promise has been resolved) and the second parameter indicates the resolved value.| + | Type | Description | + | -------- | -------- | + | Function | Callback, in which the first parameter indicates the cause of the rejection (the value is **null** if the promise has been resolved) and the second parameter indicates the resolved value. | **Example** ```js @@ -107,14 +107,14 @@ Processes an asynchronous function and returns a promise version. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| original | Function | Yes| Asynchronous function.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | original | Function | Yes | Asynchronous function. | **Return value** -| Type| Description| -| -------- | -------- | -| Function | Function in the error-first style (that is, **(err, value) =>...** is called as the last parameter) and the promise version.| + | Type | Description | + | -------- | -------- | + | Function | Function in the error-first style (that is, **(err, value) =>...** is called as the last parameter) and the promise version. | **Example** ```js @@ -138,11 +138,11 @@ Processes an asynchronous function and returns a promise version. **System capability**: SystemCapability.Utils.Lang -| Name| Type| Readable| Writable| Description| -| -------- | -------- | -------- | -------- | -------- | -| encoding | string | Yes| No| Encoding format.
- Supported formats: utf-8, ibm866, iso-8859-2, iso-8859-3, iso-8859-4, iso-8859-5, iso-8859-6, iso-8859-7, iso-8859-8, iso-8859-8-i, iso-8859-10, iso-8859-13, iso-8859-14, iso-8859-15, koi8-r, koi8-u, macintosh, windows-874, windows-1250, windows-1251, windows-1252, windows-1253, windows-1254, windows-1255, windows-1256, windows-1257, windows-1258, x-mac-cyrilli, gbk, gb18030, big5, euc-jp, iso-2022-jp, shift_jis, euc-kr, utf-16be, utf-16le| -| fatal | boolean | Yes| No| Whether to display fatal errors.| -| ignoreBOM | boolean | Yes| No| Whether to ignore the byte order marker (BOM). The default value is **false**, which indicates that the result contains the BOM.| + | Name | Type | Readable | Writable | Description | + | -------- | -------- | -------- | -------- | -------- | + | encoding | string | Yes | No | Encoding format.
- Supported formats: utf-8, ibm866, iso-8859-2, iso-8859-3, iso-8859-4, iso-8859-5, iso-8859-6, iso-8859-7, iso-8859-8, iso-8859-8-i, iso-8859-10, iso-8859-13, iso-8859-14, iso-8859-15, koi8-r, koi8-u, macintosh, windows-874, windows-1250, windows-1251, windows-1252, windows-1253, windows-1254, windows-1255, windows-1256, windows-1257, windows-1258, x-mac-cyrilli, gbk, gb18030, big5, euc-jp, iso-2022-jp, shift_jis, euc-kr, utf-16be, utf-16le | + | fatal | boolean | Yes | No | Whether to display fatal errors. | + | ignoreBOM | boolean | Yes | No | Whether to ignore the byte order marker (BOM). The default value is **false**, which indicates that the result contains the BOM. | ### constructor @@ -154,17 +154,17 @@ A constructor used to create a **TextDecoder** object. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| encoding | string | No| Encoding format.| -| options | Object | No| Encoding-related options, which include **fatal** and **ignoreBOM**.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | encoding | string | No | Encoding format. | + | options | Object | No | Encoding-related options, which include **fatal** and **ignoreBOM**. | **Table 1** options -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| fatal | boolean | No| Whether to display fatal errors.| -| ignoreBOM | boolean | No| Whether to ignore the BOM.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | fatal | boolean | No | Whether to display fatal errors. | + | ignoreBOM | boolean | No | Whether to ignore the BOM. | **Example** ```js @@ -181,21 +181,21 @@ Decodes the input content. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| input | Unit8Array | Yes| Uint8Array to decode.| -| options | Object | No| Options related to decoding.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | input | Unit8Array | Yes | Uint8Array to decode. | + | options | Object | No | Options related to decoding. | **Table 2** options -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| stream | boolean | No| Whether to allow data blocks in subsequent **decode()**. If data is processed in blocks, set this parameter to **true**. If this is the last data block to process or data is not divided into blocks, set this parameter to **false**. The default value is **false**.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | stream | boolean | No | Whether to allow data blocks in subsequent **decode()**. If data is processed in blocks, set this parameter to **true**. If this is the last data block to process or data is not divided into blocks, set this parameter to **false**. The default value is **false**. | **Return value** -| Type| Description| -| -------- | -------- | -| string | Data decoded.| + | Type | Description | + | -------- | -------- | + | string | Data decoded. | **Example** ```js @@ -222,9 +222,9 @@ Decodes the input content. **System capability**: SystemCapability.Utils.Lang -| Name| Type| Readable| Writable| Description| -| -------- | -------- | -------- | -------- | -------- | -| encoding | string | Yes| No| Encoding format. The default format is **utf-8**.| + | Name | Type | Readable | Writable | Description | + | -------- | -------- | -------- | -------- | -------- | + | encoding | string | Yes | No | Encoding format. The default format is **utf-8**. | ### constructor @@ -250,14 +250,14 @@ Encodes the input content. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| input | string | Yes| String to encode.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | input | string | Yes | String to encode. | **Return value** -| Type| Description| -| -------- | -------- | -| Uint8Array | Encoded text.| + | Type | Description | + | -------- | -------- | + | Uint8Array | Encoded text. | **Example** ```js @@ -276,15 +276,15 @@ Stores the UTF-8 encoded text. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| input | string | Yes| String to encode.| -| dest | Uint8Array | Yes| **Uint8Array** instance used to store the UTF-8 encoded text.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | input | string | Yes | String to encode. | + | dest | Uint8Array | Yes | **Uint8Array** instance used to store the UTF-8 encoded text. | **Return value** -| Type| Description| -| -------- | -------- | -| Uint8Array | Encoded text.| + | Type | Description | + | -------- | -------- | + | Uint8Array | Encoded text. | **Example** ```js @@ -306,10 +306,10 @@ A constructor used to create a **RationalNumber** object. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| numerator | number | Yes| Numerator, which is an integer.| -| denominator | number | Yes| Denominator, which is an integer.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | numerator | number | Yes | Numerator, which is an integer. | + | denominator | number | Yes | Denominator, which is an integer. | **Example** ```js @@ -326,14 +326,14 @@ Creates a **RationalNumber** object based on the given string. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| rationalString | string | Yes| String used to create the **RationalNumber** object.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | rationalString | string | Yes | String used to create the **RationalNumber** object. | **Return value** -| Type| Description| -| -------- | -------- | -| object | **RationalNumber** object created.| + | Type | Description | + | -------- | -------- | + | object | **RationalNumber** object created. | **Example** ```js @@ -351,14 +351,14 @@ Compares this **RationalNumber** object with a given object. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| another | RationalNumber | Yes| Object used to compare with this **RationalNumber** object.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | another | RationalNumber | Yes | Object used to compare with this **RationalNumber** object. | **Return value** -| Type| Description| -| -------- | -------- | -| number | Returns **0** if the two objects are equal; returns **1** if the given object is less than this object; return **-1** if the given object is greater than this object.| + | Type | Description | + | -------- | -------- | + | number | Returns **0** if the two objects are equal; returns **1** if the given object is less than this object; return **-1** if the given object is greater than this object. | **Example** @@ -378,9 +378,9 @@ Obtains the value of this **RationalNumber** object as an integer or a floating- **System capability**: SystemCapability.Utils.Lang **Return value** -| Type| Description| -| -------- | -------- | -| number | An integer or a floating-point number.| + | Type | Description | + | -------- | -------- | + | number | An integer or a floating-point number. | **Example** ```js @@ -398,14 +398,14 @@ Checks whether this **RationalNumber** object equals the given object. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| object | Object | Yes| Object used to compare with this **RationalNumber** object.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | object | Object | Yes | Object used to compare with this **RationalNumber** object. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the two objects are equal; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the two objects are equal; returns **false** otherwise. | **Example** ```js @@ -424,15 +424,15 @@ Obtains the greatest common divisor of two specified integers. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| number1 | number | Yes| The first integer used to get the greatest common divisor.| -| number2 | number | Yes| The second integer used to get the greatest common divisor.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | number1 | number | Yes | The first integer used to get the greatest common divisor. | + | number2 | number | Yes | The second integer used to get the greatest common divisor. | **Return value** -| Type| Description| -| -------- | -------- | -| number | Greatest common divisor obtained.| + | Type | Description | + | -------- | -------- | + | number | Greatest common divisor obtained. | **Example** ```js @@ -451,9 +451,9 @@ Obtains the numerator of this **RationalNumber** object. **Return value** -| Type| Description| -| -------- | -------- | -| number | Numerator of this **RationalNumber** object.| + | Type | Description | + | -------- | -------- | + | number | Numerator of this **RationalNumber** object. | **Example** ```js @@ -471,9 +471,9 @@ Obtains the denominator of this **RationalNumber** object. **System capability**: SystemCapability.Utils.Lang **Return value** -| Type| Description| -| -------- | -------- | -| number | Denominator of this **RationalNumber** object.| + | Type | Description | + | -------- | -------- | + | number | Denominator of this **RationalNumber** object. | **Example** ```js @@ -491,9 +491,9 @@ Checks whether this **RationalNumber** object is **0**. **System capability**: SystemCapability.Utils.Lang **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the value of this **RationalNumber** object is **0**; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the value of this **RationalNumber** object is **0**; returns **false** otherwise. | **Example** ```js @@ -511,9 +511,9 @@ Checks whether this **RationalNumber** object is a Not a Number (NaN). **System capability**: SystemCapability.Utils.Lang **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if this **RationalNumber** object is a NaN (the denominator and numerator are both **0**); returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if this **RationalNumber** object is a NaN (the denominator and numerator are both **0**); returns **false** otherwise. | **Example** ```js @@ -531,9 +531,9 @@ Checks whether this **RationalNumber** object represents a finite value. **System capability**: SystemCapability.Utils.Lang **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if this **RationalNumber** object represents a finite value (the denominator is not **0**); returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if this **RationalNumber** object represents a finite value (the denominator is not **0**); returns **false** otherwise. | **Example** ```js @@ -551,9 +551,9 @@ Obtains the string representation of this **RationalNumber** object. **System capability**: SystemCapability.Utils.Lang **Return value** -| Type| Description| -| -------- | -------- | -| string | Returns **NaN** if the numerator and denominator of this object are both **0**; returns a string in Numerator/Denominator format otherwise, for example, **3/5**.| + | Type | Description | + | -------- | -------- | + | string | Returns **NaN** if the numerator and denominator of this object are both **0**; returns a string in Numerator/Denominator format otherwise, for example, **3/5**. | **Example** ```js @@ -567,9 +567,9 @@ Obtains the string representation of this **RationalNumber** object. **System capability**: SystemCapability.Utils.Lang -| Name| Type| Readable| Writable| Description| -| -------- | -------- | -------- | -------- | -------- | -| length | number | Yes| No| Total number of values in this buffer.| + | Name | Type | Readable | Writable | Description | + | -------- | -------- | -------- | -------- | -------- | + | length | number | Yes | No | Total number of values in this buffer. | **Example** ```js @@ -589,9 +589,9 @@ A constructor used to create an **LruBuffer** instance. The default capacity of **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| capacity | number | No| Capacity of the **LruBuffer** to create.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | capacity | number | No | Capacity of the **LruBuffer** to create. | **Example** ```js @@ -608,9 +608,9 @@ Changes the **LruBuffer** capacity. If the new capacity is less than or equal to **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| newCapacity | number | Yes| New capacity of the **LruBuffer**.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | newCapacity | number | Yes | New capacity of the **LruBuffer**. | **Example** ```js @@ -628,9 +628,9 @@ Obtains the string representation of this **LruBuffer** object. **System capability**: SystemCapability.Utils.Lang **Return value** -| Type| Description| -| -------- | -------- | -| string | String representation of this **LruBuffer** object.| + | Type | Description | + | -------- | -------- | + | string | String representation of this **LruBuffer** object. | **Example** ```js @@ -651,9 +651,9 @@ Obtains the capacity of this buffer. **System capability**: SystemCapability.Utils.Lang **Return value** -| Type| Description| -| -------- | -------- | -| number | Capacity of this buffer.| + | Type | Description | + | -------- | -------- | + | number | Capacity of this buffer. | **Example** ```js @@ -688,9 +688,9 @@ Obtains the number of return values for **createDefault()**. **System capability**: SystemCapability.Utils.Lang **Return value** -| Type| Description| -| -------- | -------- | -| number | Number of return values for **createDefault()**.| + | Type | Description | + | -------- | -------- | + | number | Number of return values for **createDefault()**. | **Example** ```js @@ -709,9 +709,9 @@ Obtains the number of times that the queried values are mismatched. **System capability**: SystemCapability.Utils.Lang **Return value** -| Type| Description| -| -------- | -------- | -| number | Number of times that the queried values are mismatched.| + | Type | Description | + | -------- | -------- | + | number | Number of times that the queried values are mismatched. | **Example** ```js @@ -731,9 +731,9 @@ Obtains the number of removals from this buffer. **System capability**: SystemCapability.Utils.Lang **Return value** -| Type| Description| -| -------- | -------- | -| number | Number of removals from the buffer.| + | Type | Description | + | -------- | -------- | + | number | Number of removals from the buffer. | **Example** ```js @@ -754,9 +754,9 @@ Obtains the number of times that the queried values are matched. **System capability**: SystemCapability.Utils.Lang **Return value** -| Type| Description| -| -------- | -------- | -| number | Number of times that the queried values are matched.| + | Type | Description | + | -------- | -------- | + | number | Number of times that the queried values are matched. | **Example** ```js @@ -776,9 +776,9 @@ Obtains the number of additions to this buffer. **System capability**: SystemCapability.Utils.Lang **Return value** -| Type| Description| -| -------- | -------- | -| number | Number of additions to the buffer.| + | Type | Description | + | -------- | -------- | + | number | Number of additions to the buffer. | **Example** ```js @@ -797,9 +797,9 @@ Checks whether this buffer is empty. **System capability**: SystemCapability.Utils.Lang **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the buffer does not contain any value.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the buffer does not contain any value. | **Example** ```js @@ -811,21 +811,21 @@ Checks whether this buffer is empty. ### get8+ -get(key: K): V | undefined +get(key: K): V | undefined Obtains the value of the specified key. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| key | K | Yes| Key based on which the value is queried.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | key | K | Yes | Key based on which the value is queried. | **Return value** -| Type| Description| -| -------- | -------- | -| V \| undefind | Returns the value of the key if a match is found in the buffer; returns **undefined** otherwise.| + | Type | Description | + | -------- | -------- | + | V \ | undefind | Returns the value of the key if a match is found in the buffer; returns **undefined** otherwise. | **Example** ```js @@ -844,15 +844,15 @@ Adds a key-value pair to this buffer. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| key | K | Yes| Key of the key-value pair to add.| -| value | V | Yes| Value of the key-value pair to add.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | key | K | Yes | Key of the key-value pair to add. | + | value | V | Yes | Value of the key-value pair to add. | **Return value** -| Type| Description| -| -------- | -------- | -| V | Returns the existing value if the key already exists; returns the value added otherwise. If the key or value is null, an exception will be thrown. | + | Type | Description | + | -------- | -------- | + | V | Returns the existing value if the key already exists; returns the value added otherwise. If the key or value is null, an exception will be thrown. | **Example** ```js @@ -870,9 +870,9 @@ Obtains all values in this buffer, listed from the most to the least recently ac **System capability**: SystemCapability.Utils.Lang **Return value** -| Type| Description| -| -------- | -------- | -| V [] | All values in the buffer, listed from the most to the least recently accessed.| + | Type | Description | + | -------- | -------- | + | V [] | All values in the buffer, listed from the most to the least recently accessed. | **Example** ```js @@ -893,9 +893,9 @@ Obtains all keys in this buffer, listed from the most to the least recently acce **System capability**: SystemCapability.Utils.Lang **Return value** -| Type| Description| -| -------- | -------- | -| K [] | All keys in the buffer, listed from the most to the least recently accessed.| + | Type | Description | + | -------- | -------- | + | K [] | All keys in the buffer, listed from the most to the least recently accessed. | **Example** ```js @@ -907,21 +907,21 @@ Obtains all keys in this buffer, listed from the most to the least recently acce ### remove8+ -remove(key: K): V | undefined +remove(key: K): V | undefined Removes the specified key and its value from this buffer. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| key | K | Yes| Key to remove.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | key | K | Yes | Key to remove. | **Return value** -| Type| Description| -| -------- | -------- | -| V \| undefind | Returns an **Optional** object containing the removed key-value pair if the key exists in the buffer; returns an empty **Optional** object otherwise. If the key is null, an exception will be thrown.| + | Type | Description | + | -------- | -------- | + | V \ | undefind | Returns an **Optional** object containing the removed key-value pair if the key exists in the buffer; returns an empty **Optional** object otherwise. If the key is null, an exception will be thrown. | **Example** ```js @@ -940,12 +940,12 @@ Performs subsequent operations after a value is removed. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| isEvict | boolean | No| Whether the buffer capacity is insufficient. If the value is **true**, this method is called due to insufficient capacity.| -| key | K | Yes| Key removed.| -| value | V | Yes| Value removed.| -| newValue | V | No| New value for the key if the **put()** method is called and the key to be added already exists. In other cases, this parameter is left blank.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | isEvict | boolean | No | Whether the buffer capacity is insufficient. If the value is **true**, this method is called due to insufficient capacity. | + | key | K | Yes | Key removed. | + | value | V | Yes | Value removed. | + | newValue | V | No | New value for the key if the **put()** method is called and the key to be added already exists. In other cases, this parameter is left blank. | **Example** ```js @@ -985,14 +985,14 @@ Checks whether this buffer contains the specified key. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| key | K | Yes| Key to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | key | K | Yes | Key to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the buffer contains the specified key; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the buffer contains the specified key; returns **false** otherwise. | **Example** ```js @@ -1011,14 +1011,14 @@ Creates a value if the value of the specified key is not available. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| key | K | Yes| Key of which the value is missing.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | key | K | Yes | Key of which the value is missing. | **Return value** -| Type| Description| -| -------- | -------- | -| V | Value of the key.| + | Type | Description | + | -------- | -------- | + | V | Value of the key. | **Example** ```js @@ -1036,9 +1036,9 @@ Obtains a new iterator object that contains all key-value pairs in this object. **System capability**: SystemCapability.Utils.Lang **Return value** -| Type| Description| -| -------- | -------- | -| [K, V] | Iterable array.| + | Type | Description | + | -------- | -------- | + | [K, V] | Iterable array. | **Example** ```js @@ -1057,9 +1057,9 @@ Obtains a two-dimensional array in key-value pairs. **System capability**: SystemCapability.Utils.Lang **Return value** -| Type| Description| -| -------- | -------- | -| [K, V] | Two-dimensional array in key-value pairs.| + | Type | Description | + | -------- | -------- | + | [K, V] | Two-dimensional array in key-value pairs. | **Example** ```js @@ -1081,7 +1081,7 @@ The values of the **ScopeComparable** type are used to implement the **compareTo interface ScopeComparable{ compareTo(other: ScopeComparable): boolean; } -type ScopeType = ScopeComparable | number; +type ScopeType = ScopeComparable | number; ``` @@ -1116,10 +1116,10 @@ A constructor used to create a **Scope** object with the specified upper and low **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| lowerObj | [ScopeType](#scopetype8) | Yes| Lower limit of the **Scope** object.| -| upperObj | [ScopeType](#scopetype8) | Yes| Upper limit of the **Scope** object.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | lowerObj | [ScopeType](#scopetype8) | Yes | Lower limit of the **Scope** object. | + | upperObj | [ScopeType](#scopetype8) | Yes | Upper limit of the **Scope** object. | **Example** ```js @@ -1138,9 +1138,9 @@ Obtains a string representation that contains this **Scope**. **System capability**: SystemCapability.Utils.Lang **Return value** -| Type| Description| -| -------- | -------- | -| string | String representation containing the **Scope**.| + | Type | Description | + | -------- | -------- | + | string | String representation containing the **Scope**. | **Example** ```js @@ -1160,14 +1160,14 @@ Obtains the intersection of this **Scope** and the given **Scope**. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| range | [Scope](#scope8) | Yes| **Scope** specified.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | range | [Scope](#scope8) | Yes | **Scope** specified. | **Return value** -| Type| Description| -| -------- | -------- | -| [Scope](#scope8) | Intersection of this **Scope** and the given **Scope**.| + | Type | Description | + | -------- | -------- | + | [Scope](#scope8) | Intersection of this **Scope** and the given **Scope**. | **Example** ```js @@ -1190,15 +1190,15 @@ Obtains the intersection of this **Scope** and the given lower and upper limits. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| lowerObj | [ScopeType](#scopetype8) | Yes| Lower limit.| -| upperObj | [ScopeType](#scopetype8) | Yes| Upper limit.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | lowerObj | [ScopeType](#scopetype8) | Yes | Lower limit. | + | upperObj | [ScopeType](#scopetype8) | Yes | Upper limit. | **Return value** -| Type| Description| -| -------- | -------- | -| [Scope](#scope8) | Intersection of this **Scope** and the given lower and upper limits.| + | Type | Description | + | -------- | -------- | + | [Scope](#scope8) | Intersection of this **Scope** and the given lower and upper limits. | **Example** ```js @@ -1221,9 +1221,9 @@ Obtains the upper limit of this **Scope**. **Return value** -| Type| Description| -| -------- | -------- | -| [ScopeType](#scopetype8) | Upper limit of this **Scope**.| + | Type | Description | + | -------- | -------- | + | [ScopeType](#scopetype8) | Upper limit of this **Scope**. | **Example** ```js @@ -1243,9 +1243,9 @@ Obtains the lower limit of this **Scope**. **System capability**: SystemCapability.Utils.Lang **Return value** -| Type| Description| -| -------- | -------- | -| [ScopeType](#scopetype8) | Lower limit of this **Scope**.| + | Type | Description | + | -------- | -------- | + | [ScopeType](#scopetype8) | Lower limit of this **Scope**. | **Example** ```js @@ -1265,15 +1265,15 @@ Obtains the union set of this **Scope** and the given lower and upper limits. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| lowerObj | [ScopeType](#scopetype8) | Yes| Lower limit.| -| upperObj | [ScopeType](#scopetype8) | Yes| Upper limit.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | lowerObj | [ScopeType](#scopetype8) | Yes | Lower limit. | + | upperObj | [ScopeType](#scopetype8) | Yes | Upper limit. | **Return value** -| Type| Description| -| -------- | -------- | -| [Scope](#scope8) | Union set of this **Scope** and the given lower and upper limits.| + | Type | Description | + | -------- | -------- | + | [Scope](#scope8) | Union set of this **Scope** and the given lower and upper limits. | **Example** ```js @@ -1295,14 +1295,14 @@ Obtains the union set of this **Scope** and the given **Scope**. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| range | [Scope](#scope8) | Yes| **Scope** specified.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | range | [Scope](#scope8) | Yes | **Scope** specified. | **Return value** -| Type| Description| -| -------- | -------- | -| [Scope](#scope8) | Union set of this **Scope** and the given **Scope**.| + | Type | Description | + | -------- | -------- | + | [Scope](#scope8) | Union set of this **Scope** and the given **Scope**. | **Example** ```js @@ -1325,14 +1325,14 @@ Obtains the union set of this **Scope** and the given value. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | [ScopeType](#scopetype8) | Yes| Value specified.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | [ScopeType](#scopetype8) | Yes | Value specified. | **Return value** -| Type| Description| -| -------- | -------- | -| [Scope](#scope8) | Union set of this **Scope** and the given value.| + | Type | Description | + | -------- | -------- | + | [Scope](#scope8) | Union set of this **Scope** and the given value. | **Example** ```js @@ -1353,14 +1353,14 @@ Checks whether a value is within this **Scope**. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | [ScopeType](#scopetype8) | Yes| Value specified.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | [ScopeType](#scopetype8) | Yes | Value specified. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the value is within this **Scope**; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the value is within this **Scope**; returns **false** otherwise. | **Example** ```js @@ -1381,14 +1381,14 @@ Checks whether a range is within this **Scope**. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| range | [Scope](#scope8) | Yes| **Scope** specified.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | range | [Scope](#scope8) | Yes | **Scope** specified. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the range is within this **Scope**; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the range is within this **Scope**; returns **false** otherwise. | **Example** ```js @@ -1411,14 +1411,14 @@ Limits a value to this **Scope**. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | [ScopeType](#scopetype8) | Yes| Value specified.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | [ScopeType](#scopetype8) | Yes | Value specified. | **Return value** -| Type| Description| -| -------- | -------- | -| [ScopeType](#scopetype8) | Returns **lowerObj** if the specified value is less than the lower limit; returns **upperObj** if the specified value is greater than the upper limit; returns the specified value if it is within this **Scope**.| + | Type | Description | + | -------- | -------- | + | [ScopeType](#scopetype8) | Returns **lowerObj** if the specified value is less than the lower limit; returns **upperObj** if the specified value is greater than the upper limit; returns the specified value if it is within this **Scope**. | **Example** ```js @@ -1456,14 +1456,14 @@ Encodes the input content. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| src | Uint8Array | Yes| Uint8Array to encode.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | src | Uint8Array | Yes | Uint8Array to encode. | **Return value** -| Type| Description| -| -------- | -------- | -| Uint8Array | Uint8Array encoded.| + | Type | Description | + | -------- | -------- | + | Uint8Array | Uint8Array encoded. | **Example** ```js @@ -1482,14 +1482,14 @@ Encodes the input content. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| src | Uint8Array | Yes| Uint8Array to encode.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | src | Uint8Array | Yes | Uint8Array to encode. | **Return value** -| Type| Description| -| -------- | -------- | -| string | String encoded from the Uint8Array.| + | Type | Description | + | -------- | -------- | + | string | String encoded from the Uint8Array. | **Example** ```js @@ -1501,21 +1501,21 @@ Encodes the input content. ### decodeSync8+ -decodeSync(src: Uint8Array | string): Uint8Array +decodeSync(src: Uint8Array | string): Uint8Array Decodes the input content. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| src | Uint8Array \| string | Yes| Uint8Array or string to decode.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | src | Uint8Array \ | string | Yes | Uint8Array or string to decode. | **Return value** -| Type| Description| -| -------- | -------- | -| Uint8Array | Uint8Array decoded.| + | Type | Description | + | -------- | -------- | + | Uint8Array | Uint8Array decoded. | **Example** ```js @@ -1534,14 +1534,14 @@ Encodes the input content asynchronously. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| src | Uint8Array | Yes| Uint8Array to encode asynchronously.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | src | Uint8Array | Yes | Uint8Array to encode asynchronously. | **Return value** -| Type| Description| -| -------- | -------- | -| Promise<Uint8Array> | Uint8Array obtained after asynchronous encoding.| + | Type | Description | + | -------- | -------- | + | Promise<Uint8Array> | Uint8Array obtained after asynchronous encoding. | **Example** ```js @@ -1565,14 +1565,14 @@ Encodes the input content asynchronously. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| src | Uint8Array | Yes| Uint8Array to encode asynchronously.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | src | Uint8Array | Yes | Uint8Array to encode asynchronously. | **Return value** -| Type| Description| -| -------- | -------- | -| Promise<string> | String obtained after asynchronous encoding.| + | Type | Description | + | -------- | -------- | + | Promise<string> | String obtained after asynchronous encoding. | **Example** ```js @@ -1586,21 +1586,21 @@ Encodes the input content asynchronously. ### decode8+ -decode(src: Uint8Array | string): Promise<Uint8Array> +decode(src: Uint8Array | string): Promise<Uint8Array> Decodes the input content asynchronously. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| src | Uint8Array \| string | Yes| Uint8Array or string to decode asynchronously.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | src | Uint8Array \ | string | Yes | Uint8Array or string to decode asynchronously. | **Return value** -| Type| Description| -| -------- | -------- | -| Promise<Uint8Array> | Uint8Array obtained after asynchronous decoding.| + | Type | Description | + | -------- | -------- | + | Promise<Uint8Array> | Uint8Array obtained after asynchronous decoding. | **Example** ```js @@ -1641,14 +1641,14 @@ Checks whether the input value is of the **ArrayBuffer** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **ArrayBuffer** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **ArrayBuffer** type; returns **false** otherwise. | **Example** ```js @@ -1668,14 +1668,14 @@ Checks whether the input value is of the **ArrayBufferView** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **ArrayBufferView** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **ArrayBufferView** type; returns **false** otherwise. | **Example** ```js @@ -1693,14 +1693,14 @@ Checks whether the input value is of the **arguments** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **arguments** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **arguments** type; returns **false** otherwise. | **Example** ```js @@ -1721,14 +1721,14 @@ Checks whether the input value is of the **ArrayBuffer** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **ArrayBuffer** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **ArrayBuffer** type; returns **false** otherwise. | **Example** ```js @@ -1746,14 +1746,14 @@ Checks whether the input value is an asynchronous function. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is an asynchronous function; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is an asynchronous function; returns **false** otherwise. | **Example** ```js @@ -1771,14 +1771,14 @@ Checks whether the input value is of the **Boolean** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **Boolean** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **Boolean** type; returns **false** otherwise. | **Example** ```js @@ -1796,14 +1796,14 @@ Checks whether the input value is of the **Boolean**, **Number**, **String**, or **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **Boolean**, **Number**, **String**, or **Symbol** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **Boolean**, **Number**, **String**, or **Symbol** type; returns **false** otherwise. | **Example** ```js @@ -1821,14 +1821,14 @@ Checks whether the input value is of the **DataView** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **DataView** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **DataView** type; returns **false** otherwise. | **Example** ```js @@ -1847,14 +1847,14 @@ Checks whether the input value is of the **Date** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **Date** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **Date** type; returns **false** otherwise. | **Example** ```js @@ -1872,14 +1872,14 @@ Checks whether the input value is of the **native external** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **native external** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **native external** type; returns **false** otherwise. | **Example** ```js @@ -1898,14 +1898,14 @@ Checks whether the input value is of the **Float32Array** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **Float32Array** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **Float32Array** type; returns **false** otherwise. | **Example** ```js @@ -1923,14 +1923,14 @@ Checks whether the input value is of the **Float64Array** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **Float64Array** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **Float64Array** type; returns **false** otherwise. | **Example** ```js @@ -1948,14 +1948,14 @@ Checks whether the input value is a generator function. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is a generator function; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is a generator function; returns **false** otherwise. | **Example** ```js @@ -1973,14 +1973,14 @@ Checks whether the input value is a generator object. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is a generator object; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is a generator object; returns **false** otherwise. | **Example** ```js @@ -2000,14 +2000,14 @@ Checks whether the input value is of the **Int8Array** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **Int8Array** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **Int8Array** type; returns **false** otherwise. | **Example** ```js @@ -2025,14 +2025,14 @@ Checks whether the input value is of the **Int16Array** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **Int16Array** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **Int16Array** type; returns **false** otherwise. | **Example** ```js @@ -2050,14 +2050,14 @@ Checks whether the input value is of the **Int32Array** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **Int32Array** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **Int32Array** type; returns **false** otherwise. | **Example** ```js @@ -2075,14 +2075,14 @@ Checks whether the input value is of the **Map** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **Map** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **Map** type; returns **false** otherwise. | **Example** ```js @@ -2100,14 +2100,14 @@ Checks whether the input value is of the **MapIterator** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **MapIterator** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **MapIterator** type; returns **false** otherwise. | **Example** ```js @@ -2126,14 +2126,14 @@ Checks whether the input value is of the **Error** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **Error** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **Error** type; returns **false** otherwise. | **Example** ```js @@ -2151,14 +2151,14 @@ Checks whether the input value is a number object. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is a number object; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is a number object; returns **false** otherwise. | **Example** ```js @@ -2176,14 +2176,14 @@ Checks whether the input value is a promise. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is a promise; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is a promise; returns **false** otherwise. | **Example** ```js @@ -2201,14 +2201,14 @@ Checks whether the input value is a proxy. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is a proxy; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is a proxy; returns **false** otherwise. | **Example** ```js @@ -2228,14 +2228,14 @@ Checks whether the input value is of the **RegExp** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **RegExp** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **RegExp** type; returns **false** otherwise. | **Example** ```js @@ -2253,14 +2253,14 @@ Checks whether the input value is of the **Set** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **Set** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **Set** type; returns **false** otherwise. | **Example** ```js @@ -2278,14 +2278,14 @@ Checks whether the input value is of the **SetIterator** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **SetIterator** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **SetIterator** type; returns **false** otherwise. | **Example** ```js @@ -2304,14 +2304,14 @@ Checks whether the input value is a string object. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is a string object; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is a string object; returns **false** otherwise. | **Example** ```js @@ -2329,14 +2329,14 @@ Checks whether the input value is a symbol object. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is a symbol object; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is a symbol object; returns **false** otherwise. | **Example** ```js @@ -2357,14 +2357,14 @@ Checks whether the input value is of the **TypedArray** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **TypedArray** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **TypedArray** type; returns **false** otherwise. | **Example** ```js @@ -2382,14 +2382,14 @@ Checks whether the input value is of the **Uint8Array** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **Uint8Array** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **Uint8Array** type; returns **false** otherwise. | **Example** ```js @@ -2407,14 +2407,14 @@ Checks whether the input value is of the **Uint8ClampedArray** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **Uint8ClampedArray** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **Uint8ClampedArray** type; returns **false** otherwise. | **Example** ```js @@ -2432,14 +2432,14 @@ Checks whether the input value is of the **Uint16Array** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **Uint16Array** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **Uint16Array** type; returns **false** otherwise. | **Example** ```js @@ -2457,14 +2457,14 @@ Checks whether the input value is of the **Uint32Array** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **Uint32Array** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **Uint32Array** type; returns **false** otherwise. | **Example** ```js @@ -2482,14 +2482,14 @@ Checks whether the input value is of the **WeakMap** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **WeakMap** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **WeakMap** type; returns **false** otherwise. | **Example** ```js @@ -2507,17 +2507,17 @@ Checks whether the input value is of the **WeakSet** type. **System capability**: SystemCapability.Utils.Lang **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | Object | Yes| Object to check.| + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | Object | Yes | Object to check. | **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the input value is of the **WeakSet** type; returns **false** otherwise.| + | Type | Description | + | -------- | -------- | + | boolean | Returns **true** if the input value is of the **WeakSet** type; returns **false** otherwise. | **Example** ```js var that = new util.types(); var result = that.isWeakSet(new WeakSet()); - ``` + ``` \ No newline at end of file diff --git a/en/application-dev/reference/apis/js-apis-vibrator.md b/en/application-dev/reference/apis/js-apis-vibrator.md index 1251c4b6d0a6cb4b9f88b555101e230972906b05..6ea1af902df9dd714aa0e3476c3419011a21f2d2 100644 --- a/en/application-dev/reference/apis/js-apis-vibrator.md +++ b/en/application-dev/reference/apis/js-apis-vibrator.md @@ -1,6 +1,6 @@ # Vibrator -> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** +> **NOTE**
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -23,14 +23,14 @@ Triggers vibration with a specific duration. This API uses a promise to return t **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------ | ---- | ------------ | -| duration | number | Yes | Vibration duration.| + | Name | Type | Mandatory | Description | + | -------- | ------ | ---- | ------------ | + | duration | number | Yes | Vibration duration. | **Return value** -| Type | Description | -| ------------------- | ----------- | -| Promise<void> | Promise used to indicate whether the vibration is triggered successfully.| + | Type | Description | + | ------------------- | ----------- | + | Promise<void> | Promise used to indicate whether the vibration is triggered successfully. | **Example** @@ -54,10 +54,10 @@ Triggers vibration with a specific duration. This API uses an asynchronous callb **System capability**: SystemCapability.Sensors.MiscDevice **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------- | ---- | ----------------------- | -| duration | number | Yes | Vibration duration. | -| callback | AsyncCallback<void> | No | Callback used to indicate whether the vibration is triggered successfully.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------- | ---- | ----------------------- | + | duration | number | Yes | Vibration duration. | + | callback | AsyncCallback<void> | No | Callback used to indicate whether the vibration is triggered successfully. | **Example** ``` @@ -82,14 +82,14 @@ Triggers vibration with a specific effect. This API uses a promise to return the **System capability**: SystemCapability.Sensors.MiscDevice **Parameters** -| Name | Type | Mandatory | Description | -| -------- | --------------------- | ---- | ------------- | -| effectId | [EffectId](#effectid) | Yes | String that indicates the vibration effect.| + | Name | Type | Mandatory | Description | + | -------- | --------------------- | ---- | ------------- | + | effectId | [EffectId](#effectid) | Yes | String that indicates the vibration effect. | **Return value** -| Type | Description | -| ------------------- | ----------- | -| Promise<void> | Promise used to indicate whether the vibration is triggered successfully.| + | Type | Description | + | ------------------- | ----------- | + | Promise<void> | Promise used to indicate whether the vibration is triggered successfully. | **Example** ``` @@ -112,10 +112,10 @@ Triggers vibration with a specific effect. This API uses an asynchronous callbac **System capability**: SystemCapability.Sensors.MiscDevice **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------- | ---- | ----------------------- | -| effectId | [EffectId](#effectid) | Yes | String that indicates the vibration effect. | -| callback | AsyncCallback<void> | No | Callback used to indicate whether the vibration is triggered successfully.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------- | ---- | ----------------------- | + | effectId | [EffectId](#effectid) | Yes | String that indicates the vibration effect. | + | callback | AsyncCallback<void> | No | Callback used to indicate whether the vibration is triggered successfully. | **Example** ``` @@ -140,14 +140,14 @@ Stops the vibration based on the specified **stopMode**. This API uses a promise **System capability**: SystemCapability.Sensors.MiscDevice **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------------------- | ---- | --------------- | -| stopMode | [VibratorStopMode](#vibratorstopmode) | Yes | Vibration mode to stop.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------------------- | ---- | --------------- | + | stopMode | [VibratorStopMode](#vibratorstopmode) | Yes | Vibration mode to stop. | **Return value** -| Type | Description | -| ------------------- | ----------- | -| Promise<void> | Promise used to indicate whether the vibration is stopped successfully.| + | Type | Description | + | ------------------- | ----------- | + | Promise<void> | Promise used to indicate whether the vibration is stopped successfully. | **Example** ``` @@ -170,10 +170,10 @@ Stops the vibration based on the specified **stopMode**. This API uses an asynch **System capability**: SystemCapability.Sensors.MiscDevice **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------------------- | ---- | ----------------------- | -| stopMode | [VibratorStopMode](#vibratorstopmode) | Yes | Vibration mode to stop. | -| callback | AsyncCallback<void> | No | Callback used to indicate whether the vibration is stopped successfully.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------------------- | ---- | ----------------------- | + | stopMode | [VibratorStopMode](#vibratorstopmode) | Yes | Vibration mode to stop. | + | callback | AsyncCallback<void> | No | Callback used to indicate whether the vibration is stopped successfully. | **Example** ``` @@ -193,9 +193,9 @@ Describes the vibration effect. **System capability**: SystemCapability.Sensors.MiscDevice -| Name | Default Value | Description | -| ------------------ | -------------------- | --------------- | -| EFFECT_CLOCK_TIMER | "haptic.clock.timer" | Vibration effect of the vibrator when a user adjusts the timer.| + | Name | Default Value | Description | + | ------------------ | -------------------- | --------------------------------------------------------------- | + | EFFECT_CLOCK_TIMER | "haptic.clock.timer" | Vibration effect of the vibrator when a user adjusts the timer. | ## VibratorStopMode @@ -204,7 +204,7 @@ Describes the vibration mode to stop. **System capability**: SystemCapability.Sensors.MiscDevice -| Name | Default Value | Description | -| ------------------------- | -------- | ---------------------------------------- | -| VIBRATOR_STOP_MODE_TIME | "time" | The vibration to stop is in **duration** mode. This vibration is triggered with the parameter **duration** of the **number** type.| -| VIBRATOR_STOP_MODE_PRESET | "preset" | The vibration to stop is in **EffectId** mode. This vibration is triggered with the parameter **effectId** of the **EffectId** type.| + | Name | Default Value | Description | + | ------------------------- | -------- | ---------------------------------------- | + | VIBRATOR_STOP_MODE_TIME | "time" | The vibration to stop is in **duration** mode. This vibration is triggered with the parameter **duration** of the **number** type. | + | VIBRATOR_STOP_MODE_PRESET | "preset" | The vibration to stop is in **EffectId** mode. This vibration is triggered with the parameter **effectId** of the **EffectId** type. | diff --git a/en/application-dev/reference/apis/js-apis-window.md b/en/application-dev/reference/apis/js-apis-window.md index 358dead42d99dc9a23977d1e9299c5f5e01ae27b..4c4f1e76a0fbfb8d847f092698a27899fba367d3 100644 --- a/en/application-dev/reference/apis/js-apis-window.md +++ b/en/application-dev/reference/apis/js-apis-window.md @@ -2,7 +2,8 @@ The **Window** module provides basic capabilities for managing windows, including creating and destroying windows and setting serial port attributes. -> **NOTE**
+> **NOTE**
+> > The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. ## Modules to Import @@ -136,20 +137,19 @@ Describes the window properties. **System capability**: SystemCapability.WindowManager.WindowManager.Core -| Name | Type | Readable| Writable| Description | -| ------------------------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ | -| windowRect7+ | [Rect](#rect) | Yes | Yes | Window size. | -| type7+ | [WindowType](#windowtype) | Yes | Yes | Window type. | -| isFullScreen | boolean | Yes | Yes | Whether the window is displayed in full screen mode. The default value is **false**. | -| isLayoutFullScreen7+ | boolean | Yes | Yes | Whether the window layout is in full-screen mode (whether the window is immersive). The default value is **false**. | -| focusable7+ | boolean | Yes | No | Whether the window can gain focus. The default value is **true**. | -| touchable7+ | boolean | Yes | No | Whether the window is touchable. The default value is **true**. | -| brightness | number | Yes | Yes | Screen brightness. The value ranges from 0 to 1. The value **1** indicates the maximum brightness.
This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.| -| dimBehindValue7+ | number | Yes | Yes | Dimness of the window that is not on top. The value ranges from 0 to 1. The value **1** indicates the maximum dimness.
This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.| -| isKeepScreenOn | boolean | Yes | Yes | Whether the screen is always on. The default value is **false**.
This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.| -| isPrivacyMode7+ | boolean | Yes | Yes | Whether the window is in privacy mode. The default value is **false**.
This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.| -| isRoundCorner7+ | boolean | Yes | Yes | Whether the window has rounded corners. The default value is **false**.
This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.| -| isTransparent7+ | boolean | Yes | Yes | Whether the window is transparent. The default value is **false**.
This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.| +| Name | Type | Readable| Writable| Description | +| ------------------------------- | ------------------------- | ---- | ---- | -------------------------------------------- | +| windowRect7+ | [Rect](#rect) | Yes | Yes | Window size. | +| type7+ | [WindowType](#windowtype) | Yes | Yes | Window type. | +| isFullScreen | boolean | Yes | Yes | Whether the window is displayed in full screen mode. The default value is **false**. | +| isLayoutFullScreen7+ | boolean | Yes | Yes | Whether the window layout is in full-screen mode (whether the window is immersive). The default value is **false**. | +| focusable7+ | boolean | Yes | No | Whether the window can gain focus. The default value is **true**. | +| touchable7+ | boolean | Yes | No | Whether the window is touchable. The default value is **true**. | +| brightness | number | Yes | Yes | Screen brightness. The value ranges from 0 to 1. The value **1** indicates the maximum brightness. | +| isKeepScreenOn | boolean | Yes | Yes | Whether the screen is always on. The default value is **false**. | +| isPrivacyMode7+ | boolean | Yes | Yes | Whether the window is in privacy mode. The default value is **false**. | +| isRoundCorner7+ | boolean | Yes | Yes | Whether the window has rounded corners. The default value is **false**. | +| isTransparent7+ | boolean | Yes | Yes | Whether the window is transparent. The default value is **false**. | ## ColorSpace8+ @@ -174,11 +174,11 @@ This API is discarded since API version 8. You are advised to use [window.create **Parameters** - | Name | Type | Mandatory| Description | - | -------- | -------------------------------------- | ---- | -------------------------- | - | id | string | Yes | Window ID. | - | type | [WindowType](#windowtype) | Yes | Window type. | - | callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the subwindow created.| +| Name | Type | Mandatory| Description | +| -------- | -------------------------------------- | ---- | -------------------------- | +| id | string | Yes | Window ID. | +| type | [WindowType](#windowtype) | Yes | Window type. | +| callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the subwindow created.| **Example** @@ -207,16 +207,16 @@ This API is discarded since API version 8. You are advised to use [window.create **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------------------------- | ---- | ---------- | - | id | string | Yes | Window ID. | - | type | [WindowType](#windowtype) | Yes | Window type.| +| Name| Type | Mandatory| Description | +| ------ | ------------------------- | ---- | ---------- | +| id | string | Yes | Window ID. | +| type | [WindowType](#windowtype) | Yes | Window type.| **Return value** - | Type | Description | - | -------------------------------- | ------------------------------------------------- | - | Promise<[Window](#window)> | Promise used to return the subwindow created.| +| Type | Description | +| -------------------------------- | ------------------------------------------------- | +| Promise<[Window](#window)> | Promise used to return the subwindow created.| **Example** @@ -237,18 +237,18 @@ create(ctx: Context, id: string, type: WindowType, callback: AsyncCallback<Wi Creates a subwindow when the context is [Context](js-apis-Context.md). This API uses an asynchronous callback to return the result. -Creates a system window when the context is [ServiceExtensionContext](js-apis-service-extension-context.md), starting from API version 9. This API uses an asynchronous callback to return the result. +Creates a system window when the context is [ServiceExtensionContext](js-apis-service-extension-context.md). This API uses an asynchronous callback to return the result. It is valid since API version 9. **System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** - | Name | Type | Mandatory| Description | - | -------- | -------------------------------------- | ---- | ------------------------------------------------------------ | - | ctx | Context | Yes | Current application context.
For the definition of **Context** of API version 8, see [Context](js-apis-Context.md).
For the definition of **Context** of API version 9, see [Context](js-apis-service-extension-context.md).| - | id | string | Yes | Window ID. | - | type | [WindowType](#windowtype) | Yes | Window type. | - | callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the window created. | +| Name | Type | Mandatory| Description | +| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ | +| ctx | Context | Yes | Current application context.
For the definition of **Context** of API version 8, see [Context](js-apis-Context.md).
For the definition of **Context** of API version 9, see [Context](js-apis-service-extension-context.md).| +| id | string | Yes | Window ID. | +| type | [WindowType](#windowtype) | Yes | Window type. | +| callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the window created. | **Example** @@ -271,23 +271,23 @@ create(ctx: Context, id: string, type: WindowType): Promise<Window> Creates a subwindow when the context is [Context](js-apis-Context.md). This API uses a promise to return the result. -Creates a system window when the context is [ServiceExtensionContext](js-apis-service-extension-context.md), starting from API version 9. This API uses a promise to return the result. +Creates a system window when the context is [ServiceExtensionContext](js-apis-service-extension-context.md). This API uses a promise to return the result. It is valid since API version 9. **System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------------------------- | ---- | ------------------------------------------------------------ | - | ctx | Context | Yes | Current application context.
For the definition of **Context** of API version 8, see [Context](js-apis-Context.md).
For the definition of **Context** of API version 9, see [Context](js-apis-service-extension-context.md).| - | id | string | Yes | Window ID. | - | type | [WindowType](#windowtype) | Yes | Window type. | +| Name| Type | Mandatory| Description | +| ------ | ------------------------- | ---- | ------------------------------------------------------------ | +| ctx | Context | Yes | Current application context.
For the definition of **Context** of API version 8, see [Context](js-apis-Context.md).
For the definition of **Context** of API version 9, see [Context](js-apis-service-extension-context.md).| +| id | string | Yes | Window ID. | +| type | [WindowType](#windowtype) | Yes | Window type. | **Return value** - | Type | Description | - | -------------------------------- | ----------------------------------------------- | - | Promise<[Window](#window)> | Promise used to return the window created.| +| Type | Description | +| -------------------------------- | ----------------------------------------------- | +| Promise<[Window](#window)> | Promise used to return the window created.| **Example** @@ -312,10 +312,10 @@ Finds a window based on the ID. This API uses an asynchronous callback to return **Parameters** - | Name | Type | Mandatory| Description | - | -------- | -------------------------------------- | ---- | ---------------------------- | - | id | string | Yes | Window ID. | - | callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the window found.| +| Name | Type | Mandatory| Description | +| -------- | -------------------------------------- | ---- | ---------------------------- | +| id | string | Yes | Window ID. | +| callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the window found.| **Example** @@ -341,15 +341,15 @@ Finds a window based on the ID. This API uses a promise to return the result. **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | -------- | - | id | string | Yes | Window ID.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | -------- | +| id | string | Yes | Window ID.| **Return value** - | Type | Description | - | -------------------------------- | ----------------------------------------------- | - | Promise<[Window](#window)> | Promise used to return the window found.| +| Type | Description | +| -------------------------------- | ----------------------------------------------- | +| Promise<[Window](#window)> | Promise used to return the window found.| **Example** @@ -376,9 +376,9 @@ This API is discarded since API version 8. You are advised to use [window.getTop **Parameters** - | Name | Type | Mandatory| Description | - | -------- | -------------------------------------- | ---- | -------------------------------------- | - | callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the top window obtained.| +| Name | Type | Mandatory| Description | +| -------- | -------------------------------------- | ---- | -------------------------------------- | +| callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the top window obtained.| **Example** @@ -406,9 +406,9 @@ This API is discarded since API version 8. You are advised to use [window.getTop **Return value** - | Type | Description | - | -------------------------------- | --------------------------------------------------------- | - | Promise<[Window](#window)> | Promise used to return the top window obtained.| +| Type | Description | +| -------------------------------- | --------------------------------------------------------- | +| Promise<[Window](#window)> | Promise used to return the top window obtained.| **Example** @@ -433,10 +433,10 @@ Obtains the top window of the current application. This API uses an asynchronous **Parameters** - | Name | Type | Mandatory| Description | - | -------- | -------------------------------------- | ---- | ------------------------------------------------------------ | - | ctx | Context | Yes | Current application context.
For the definition of **Context** of API version 8, see [Context](js-apis-Context.md).
For the definition of **Context** of API version 9, see [Context](js-apis-ability-context.md).| - | callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the top window obtained. | +| Name | Type | Mandatory| Description | +| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ | +| ctx | Context | Yes | Current application context.
For the definition of **Context** of API version 8, see [Context](js-apis-Context.md).
For the definition of **Context** of API version 9, see [Context](js-apis-ability-context.md).| +| callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the top window obtained. | **Example** @@ -462,15 +462,15 @@ Obtains the top window of the current application. This API uses a promise to re **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------- | ---- | ------------------------------------------------------------ | - | ctx | Context | Yes | Current application context.
For the definition of **Context** of API version 8, see [Context](js-apis-Context.md).
For the definition of **Context** of API version 9, see [Context](js-apis-ability-context.md).| +| Name| Type | Mandatory| Description | +| ------ | ------- | ---- | ------------------------------------------------------------ | +| ctx | Context | Yes | Current application context.
For the definition of **Context** of API version 8, see [Context](js-apis-Context.md).
For the definition of **Context** of API version 9, see [Context](js-apis-ability-context.md).| **Return value** - | Type | Description | - | -------------------------------- | --------------------------------------------------------- | - | Promise<[Window](#window)> | Promise used to return the top window obtained.| +| Type | Description | +| -------------------------------- | --------------------------------------------------------- | +| Promise<[Window](#window)> | Promise used to return the top window obtained.| **Example** @@ -497,10 +497,10 @@ This is a system API and cannot be called by third-party applications. **Parameters** - | Name | Type | Mandatory| Description | - | -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | - | type | string | Yes | Type of event to listen for. The value is fixed at **systemBarTintChange**, indicating the property change event of the status bar and navigation bar.| - | callback | Callback<[SystemBarTintState](#systembartintstate)> | Yes | Callback used to return the information. | +| Name | Type | Mandatory| Description | +| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | string | Yes | Type of event to listen for. The value is fixed at **systemBarTintChange**, indicating the property change event of the status bar and navigation bar.| +| callback | Callback<[SystemBarTintState](#systembartintstate)> | Yes | Callback used to return the information. | **Example** @@ -523,10 +523,10 @@ This is a system API and cannot be called by third-party applications. **Parameters** - | Name | Type | Mandatory| Description | - | -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | - | type | string | Yes | Type of event to listen for. The value is fixed at **systemBarTintChange**, indicating the property change event of the status bar and navigation bar.| - | callback | Callback<[SystemBarTintState](#systembartintstate)> | No | Callback used to return the information. | +| Name | Type | Mandatory| Description | +| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | string | Yes | Type of event to listen for. The value is fixed at **systemBarTintChange**, indicating the property change event of the status bar and navigation bar.| +| callback | Callback<[SystemBarTintState](#systembartintstate)> | No | Callback used to return the information. | **Example** @@ -551,9 +551,9 @@ This is a system API and cannot be called by third-party applications. **Parameters** - | Name | Type | Mandatory| Description | - | -------- | ------------------------- | ---- | ---------- | - | callback | AsyncCallback<void> | Yes | Callback used to return the execution result.| +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | ---------- | +| callback | AsyncCallback<void> | Yes | Callback used to return the execution result.| **Example** @@ -579,9 +579,9 @@ This is a system API and cannot be called by third-party applications. **Return value** - | Type | Description | - | ------------------- | ----------------------------------------------- | - | Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ----------------------------------------------- | +| Promise<void> | Promise used to return the execution result.| **Example** @@ -604,9 +604,9 @@ Shows this window. This API uses an asynchronous callback to return the result. **Parameters** - | Name | Type | Mandatory| Description | - | -------- | ------------------------- | ---- | ---------- | - | callback | AsyncCallback<void> | Yes | Callback used to return the execution result.| +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | ---------- | +| callback | AsyncCallback<void> | Yes | Callback used to return the execution result.| **Example** @@ -630,9 +630,9 @@ Shows this window. This API uses a promise to return the result. **Return value** - | Type | Description | - | ------------------- | ----------------------------------------------- | - | Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ----------------------------------------------- | +| Promise<void> | Promise used to return the execution result.| **Example** @@ -655,9 +655,9 @@ Destroys this window. This API uses an asynchronous callback to return the resul **Parameters** - | Name | Type | Mandatory| Description | - | -------- | ------------------------- | ---- | ---------- | - | callback | AsyncCallback<void> | Yes | Callback used to return the execution result.| +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | ---------- | +| callback | AsyncCallback<void> | Yes | Callback used to return the execution result.| **Example** @@ -681,9 +681,9 @@ Destroys this window. This API uses a promise to return the result. **Return value** - | Type | Description | - | ------------------- | ----------------------------------------------- | - | Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ----------------------------------------------- | +| Promise<void> | Promise used to return the execution result.| **Example** @@ -700,17 +700,17 @@ Destroys this window. This API uses a promise to return the result. moveTo(x: number, y: number, callback: AsyncCallback<void>): void -Moves the position of this window. This API uses an asynchronous callback to return the result. +Moves this window. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** - | Name | Type | Mandatory| Description | - | -------- | ------------------------- | ---- | --------------------------------------- | - | x | number | Yes | Distance that the window moves along the x-axis. A positive value indicates that the window moves to the right.| - | y | number | Yes | Distance that the window moves along the y-axis. A positive value indicates that the window moves downwards.| - | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | --------------------------------------- | +| x | number | Yes | Distance that the window moves along the x-axis. A positive value indicates that the window moves to the right.| +| y | number | Yes | Distance that the window moves along the y-axis. A positive value indicates that the window moves downwards.| +| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | **Example** @@ -729,22 +729,22 @@ Moves the position of this window. This API uses an asynchronous callback to ret moveTo(x: number, y: number): Promise<void> -Moves the position of this window. This API uses a promise to return the result. +Moves this window. This API uses a promise to return the result. **System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | --------------------------------------- | - | x | number | Yes | Distance that the window moves along the x-axis. A positive value indicates that the window moves to the right.| - | y | number | Yes | Distance that the window moves along the y-axis. A positive value indicates that the window moves downwards.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | --------------------------------------- | +| x | number | Yes | Distance that the window moves along the x-axis. A positive value indicates that the window moves to the right.| +| y | number | Yes | Distance that the window moves along the y-axis. A positive value indicates that the window moves downwards.| **Return value** - | Type | Description | - | ------------------- | ----------------------------------------------- | - | Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ----------------------------------------------- | +| Promise<void> | Promise used to return the execution result.| **Example** @@ -767,11 +767,11 @@ Changes the size of this window. This API uses an asynchronous callback to retur **Parameters** - | Name | Type | Mandatory| Description | - | -------- | ------------------------- | ---- | ---------------- | - | width | number | Yes | New width of the window.| - | height | number | Yes | New height of the window.| - | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | ---------------- | +| width | number | Yes | New width of the window.| +| height | number | Yes | New height of the window.| +| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | **Example** @@ -795,16 +795,16 @@ Changes the size of this window. This API uses a promise to return the result. **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | ---------------- | - | width | number | Yes | New width of the window.| - | height | number | Yes | New height of the window.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ---------------- | +| width | number | Yes | New width of the window.| +| height | number | Yes | New height of the window.| **Return value** - | Type | Description | - | ------------------- | ----------------------------------------------- | - | Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ----------------------------------------------- | +| Promise<void> | Promise used to return the execution result.| **Example** @@ -829,10 +829,10 @@ This is a system API and cannot be called by third-party applications. **Parameters** - | Name | Type | Mandatory| Description | - | -------- | ------------------------- | ---- | ---------- | - | type | [WindowType](#windowtype) | Yes | Window type.| - | callback | AsyncCallback<void> | Yes | Callback used to return the execution result.| +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | ---------- | +| type | [WindowType](#windowtype) | Yes | Window type.| +| callback | AsyncCallback<void> | Yes | Callback used to return the execution result.| **Example** @@ -859,15 +859,15 @@ This is a system API and cannot be called by third-party applications. **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------------------------- | ---- | ---------- | - | type | [WindowType](#windowtype) | Yes | Window type.| +| Name| Type | Mandatory| Description | +| ------ | ------------------------- | ---- | ---------- | +| type | [WindowType](#windowtype) | Yes | Window type.| **Return value** - | Type | Description | - | ------------------- | ----------------------------------------------- | - | Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ----------------------------------------------- | +| Promise<void> | Promise used to return the execution result.| **Example** @@ -891,9 +891,9 @@ Obtains the properties of this window. This API uses an asynchronous callback to **Parameters** - | Name | Type | Mandatory| Description | - | -------- | ---------------------------------------------------------- | ---- | ------------------ | - | callback | AsyncCallback<[WindowProperties](#windowproperties)> | Yes | Callback used to return the window properties.| +| Name | Type | Mandatory| Description | +| -------- | ---------------------------------------------------------- | ---- | ------------------ | +| callback | AsyncCallback<[WindowProperties](#windowproperties)> | Yes | Callback used to return the window properties.| **Example** @@ -917,9 +917,9 @@ Obtains the properties of this window. This API uses a promise to return the res **Return value** - | Type | Description | - | ---------------------------------------------------- | ------------------------------------- | - | Promise<[WindowProperties](#windowproperties)> | Promise used to return the window properties.| +| Type | Description | +| ---------------------------------------------------- | ------------------------------------- | +| Promise<[WindowProperties](#windowproperties)> | Promise used to return the window properties.| **Example** @@ -942,10 +942,10 @@ Obtains the area where this window cannot be displayed, for example, the system **Parameters** - | Name | Type | Mandatory| Description | - | -------- | -------------------------------------------- | ---- | ------------------------------------------------------------ | - | type | [AvoidAreaType](#avoidareatype) | Yes | Type of the area. **TYPE_SYSTEM** indicates the default area of the system. **TYPE_CUTOUT** indicates the notch.| - | callback | AsyncCallback<[AvoidArea](#avoidarea)> | Yes | Callback used to return the area. | +| Name | Type | Mandatory| Description | +| -------- | -------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [AvoidAreaType](#avoidareatype) | Yes | Type of the area. **TYPE_SYSTEM** indicates the default area of the system. **TYPE_CUTOUT** indicates the notch.| +| callback | AsyncCallback<[AvoidArea](#avoidarea)> | Yes | Callback used to return the area. | **Example** @@ -970,15 +970,15 @@ Obtains the area where this window cannot be displayed, for example, the system **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------------------------------- | ---- | ------------------------------------------------------------ | - | type | [AvoidAreaType](#avoidareatype) | Yes | Type of the area. **TYPE_SYSTEM** indicates the default area of the system. **TYPE_CUTOUT** indicates the notch.| +| Name| Type | Mandatory| Description | +| ------ | ------------------------------- | ---- | ------------------------------------------------------------ | +| type | [AvoidAreaType](#avoidareatype) | Yes | Type of the area. **TYPE_SYSTEM** indicates the default area of the system. **TYPE_CUTOUT** indicates the notch.| **Return value** - | Type | Description | - | -------------------------------------- | --------------------------------------------- | - | Promise<[AvoidArea](#avoidarea)> | Promise used to return the area.| +| Type | Description | +| -------------------------------------- | --------------------------------------------- | +| Promise<[AvoidArea](#avoidarea)> | Promise used to return the area.| **Example** @@ -1001,10 +1001,10 @@ Sets whether to enable the full-screen mode for this window. This API uses an as **Parameters** - | Name | Type | Mandatory| Description | - | ------------ | ------------------------- | ---- | ---------------------------------------------- | - | isFullScreen | boolean | Yes | Whether to enable the full-screen mode, in which the status bar and navigation bar are hidden.| - | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | +| Name | Type | Mandatory| Description | +| ------------ | ------------------------- | ---- | ---------------------------------------------- | +| isFullScreen | boolean | Yes | Whether to enable the full-screen mode, in which the status bar and navigation bar are hidden.| +| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | **Example** @@ -1029,15 +1029,15 @@ Sets whether to enable the full-screen mode for this window. This API uses a pro **Parameters** - | Name | Type | Mandatory| Description | - | ------------ | ------- | ---- | ---------------------------------------------- | - | isFullScreen | boolean | Yes | Whether to enable the full-screen mode, in which the status bar and navigation bar are hidden.| +| Name | Type | Mandatory| Description | +| ------------ | ------- | ---- | ---------------------------------------------- | +| isFullScreen | boolean | Yes | Whether to enable the full-screen mode, in which the status bar and navigation bar are hidden.| **Return value** - | Type | Description | - | ------------------- | ----------------------------------------------- | - | Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ----------------------------------------------- | +| Promise<void> | Promise used to return the execution result.| **Example** @@ -1055,16 +1055,16 @@ Sets whether to enable the full-screen mode for this window. This API uses a pro setLayoutFullScreen(isLayoutFullScreen: boolean, callback: AsyncCallback<void>): void -Sets whether the window layout is in full-screen mode. This API uses an asynchronous callback to return the result. +Sets whether to enable the full-screen mode for the window layout. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** - | Name | Type | Mandatory| Description | - | ------------------ | ------------------------- | ---- | ------------------------------------------------------------ | - | isLayoutFullScreen | boolean | Yes | Whether the window layout is in full-screen mode, in which the status bar and navigation bar are displayed.| - | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | +| Name | Type | Mandatory| Description | +| ------------------ | ------------------------- | ---- | ------------------------------------------------------------ | +| isLayoutFullScreen | boolean | Yes | Whether to enable the full-screen mode for the window layout, in which the status bar and navigation bar are displayed.| +| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | **Example** @@ -1083,21 +1083,21 @@ Sets whether the window layout is in full-screen mode. This API uses an asynchro setLayoutFullScreen(isLayoutFullScreen: boolean): Promise<void> -Sets whether the window layout is in full-screen mode. This API uses a promise to return the result. +Sets whether to enable the full-screen mode for the window layout. This API uses a promise to return the result. **System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** - | Name | Type | Mandatory| Description | - | ------------------ | ------- | ---- | ------------------------------------------------------------ | - | isLayoutFullScreen | boolean | Yes | Whether the window layout is in full-screen mode, in which the status bar and navigation bar are displayed.| +| Name | Type | Mandatory| Description | +| ------------------ | ------- | ---- | ------------------------------------------------------------ | +| isLayoutFullScreen | boolean | Yes | Whether to enable the full-screen mode for the window layout, in which the status bar and navigation bar are displayed.| **Return value** - | Type | Description | - | ------------------- | ----------------------------------------------- | - | Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ----------------------------------------------- | +| Promise<void> | Promise used to return the execution result.| **Example** @@ -1121,10 +1121,10 @@ Sets whether to display the status bar and navigation bar in this window. This A **Parameters** - | Name | Type | Mandatory| Description | - | -------- | ------------------------- | ---- | ------------------------------------------------------------ | - | names | Array | Yes | Whether to display the status bar and navigation bar. For example, to display the status bar and navigation bar, set this parameter to **["status", "navigation"]**. By default, they are not displayed.| - | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | ------------------------------------------------------------ | +| names | Array | Yes | Whether to display the status bar and navigation bar. For example, to display the status bar and navigation bar, set this parameter to **["status", "navigation"]**. By default, they are not displayed.| +| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | **Example** @@ -1149,15 +1149,15 @@ Sets whether to display the status bar and navigation bar in this window. This A **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ----- | ---- | ------------------------------------------------------------ | - | names | Array | Yes | Whether to display the status bar and navigation bar. For example, to display the status bar and navigation bar, set this parameter to **["status", "navigation"]**. By default, they are not displayed.| +| Name| Type | Mandatory| Description | +| ------ | ----- | ---- | ------------------------------------------------------------ | +| names | Array | Yes | Whether to display the status bar and navigation bar. For example, to display the status bar and navigation bar, set this parameter to **["status", "navigation"]**. By default, they are not displayed.| **Return value** - | Type | Description | - | ------------------- | ----------------------------------------------- | - | Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ----------------------------------------------- | +| Promise<void> | Promise used to return the execution result.| **Example** @@ -1181,10 +1181,10 @@ Sets the properties of the status bar and navigation bar in this window. This AP **Parameters** - | Name | Type | Mandatory| Description | - | ------------------- | ------------------------------------------- | ---- | -------------------- | - | SystemBarProperties | [SystemBarProperties](#systembarproperties) | Yes | Properties of the status bar and navigation bar.| - | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | +| Name | Type | Mandatory| Description | +| ------------------- | ------------------------------------------- | ---- | -------------------- | +| SystemBarProperties | [SystemBarProperties](#systembarproperties) | Yes | Properties of the status bar and navigation bar.| +| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | **Example** @@ -1218,15 +1218,15 @@ Sets the properties of the status bar and navigation bar in this window. This AP **Parameters** - | Name | Type | Mandatory| Description | - | ------------------- | ------------------------------------------- | ---- | -------------------- | - | SystemBarProperties | [SystemBarProperties](#systembarproperties) | Yes | Properties of the status bar and navigation bar.| +| Name | Type | Mandatory| Description | +| ------------------- | ------------------------------------------- | ---- | -------------------- | +| SystemBarProperties | [SystemBarProperties](#systembarproperties) | Yes | Properties of the status bar and navigation bar.| **Return value** - | Type | Description | - | ------------------- | ----------------------------------------------- | - | Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ----------------------------------------------- | +| Promise<void> | Promise used to return the execution result.| **Example** @@ -1259,10 +1259,10 @@ Loads content to this window. This API uses an asynchronous callback to return t **Parameters** - | Name | Type | Mandatory| Description | - | -------- | ------------------------- | ---- | -------------------- | - | path | string | Yes | Path of the page from which the content will be loaded.| - | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | -------------------- | +| path | string | Yes | Path of the page from which the content will be loaded.| +| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | **Example** @@ -1286,15 +1286,15 @@ Loads content to this window. This API uses a promise to return the result. **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | -------------------- | - | path | string | Yes | Path of the page from which the content will be loaded.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | -------------------- | +| path | string | Yes | Path of the page from which the content will be loaded.| **Return value** - | Type | Description | - | ------------------- | ----------------------------------------------- | - | Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ----------------------------------------------- | +| Promise<void> | Promise used to return the execution result.| **Example** @@ -1317,9 +1317,9 @@ Checks whether this window is displayed. This API uses an asynchronous callback **Parameters** - | Name | Type | Mandatory| Description | - | -------- | ---------------------------- | ---- | -------------------------------- | - | callback | AsyncCallback<boolean> | Yes | Callback used to return whether the window is displayed.| +| Name | Type | Mandatory| Description | +| -------- | ---------------------------- | ---- | -------------------------------- | +| callback | AsyncCallback<boolean> | Yes | Callback used to return whether the window is displayed.| **Example** @@ -1343,9 +1343,9 @@ Checks whether this window is displayed. This API uses a promise to return the r **Return value** - | Type | Description | - | ---------------------- | ----------------------------------------------------- | - | Promise<boolean> | Promise used to return whether the window is displayed.| +| Type | Description | +| ---------------------- | ----------------------------------------------------- | +| Promise<boolean> | Promise used to return whether the window is displayed.| **Example** @@ -1368,10 +1368,10 @@ Enables listening for window size changes. **Parameters** - | Name | Type | Mandatory| Description | - | -------- | ----------------------------- | ---- | -------------------------------------------------------- | - | type | string | Yes | Type of event to listen for. The value is fixed at **windowSizeChange**, indicating the window size change event.| - | callback | Callback<[Size](#size)> | Yes | Callback used to return the information. | +| Name | Type | Mandatory| Description | +| -------- | ----------------------------- | ---- | -------------------------------------------------------- | +| type | string | Yes | Type of event to listen for. The value is fixed at **windowSizeChange**, indicating the window size change event.| +| callback | Callback<[Size](#size)> | Yes | Callback used to return the information. | **Example** @@ -1392,10 +1392,10 @@ Disables listening for window size changes. **Parameters** - | Name | Type | Mandatory| Description | - | -------- | ----------------------------- | ---- | -------------------------------------------------------- | - | type | string | Yes | Type of event to listen for. The value is fixed at **windowSizeChange**, indicating the window size change event.| - | callback | Callback<[Size](#size)> | No | Callback used to return the information. | +| Name | Type | Mandatory| Description | +| -------- | ----------------------------- | ---- | -------------------------------------------------------- | +| type | string | Yes | Type of event to listen for. The value is fixed at **windowSizeChange**, indicating the window size change event.| +| callback | Callback<[Size](#size)> | No | Callback used to return the information. | **Example** @@ -1414,10 +1414,10 @@ Enables listening for changes to the area where the window cannot be displayed. **Parameters** - | Name | Type | Mandatory| Description | - | -------- | --------------------------------------- | ---- | ------------------------------------------------------------ | - | type | string | Yes | Type of event to listen for. The value is fixed at **systemAvoidAreaChange**, indicating the event of changes to the area where the window cannot be displayed.| - | callback | Callback<[AvoidArea](#avoidarea)> | Yes | Callback used to return the information. | +| Name | Type | Mandatory| Description | +| -------- | --------------------------------------- | ---- | ------------------------------------------------------------ | +| type | string | Yes | Type of event to listen for. The value is fixed at **systemAvoidAreaChange**, indicating the event of changes to the area where the window cannot be displayed.| +| callback | Callback<[AvoidArea](#avoidarea)> | Yes | Callback used to return the information. | **Example** @@ -1438,10 +1438,10 @@ Disables listening for changes to the area where the window cannot be displayed. **Parameters** - | Name | Type | Mandatory| Description | - | -------- | --------------------------------------- | ---- | ------------------------------------------------------------ | - | type | string | Yes | Type of event to listen for. The value is fixed at **systemAvoidAreaChange**, indicating the event of changes to the area where the window cannot be displayed.| - | callback | Callback<[AvoidArea](#avoidarea)> | No | Callback used to return the information. | +| Name | Type | Mandatory| Description | +| -------- | --------------------------------------- | ---- | ------------------------------------------------------------ | +| type | string | Yes | Type of event to listen for. The value is fixed at **systemAvoidAreaChange**, indicating the event of changes to the area where the window cannot be displayed.| +| callback | Callback<[AvoidArea](#avoidarea)> | No | Callback used to return the information. | **Example** @@ -1456,16 +1456,14 @@ on(type: 'keyboardHeightChange', callback: Callback<number>): void Enables listening for keyboard height changes. -This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. - **System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** - | Name | Type | Mandatory| Description | - | -------- | ------------------ | ---- | ------------------------------------------------------------ | - | type | string | Yes | Type of event to listen for. The value is fixed at **keyboardHeightChange**, indicating the keyboard height change event.| - | callback | Callbacknumber> | Yes | Callback used to return the information. | +| Name | Type | Mandatory| Description | +| -------- | ------------------ | ---- | ------------------------------------------------------------ | +| type | string | Yes | Type of event to listen for. The value is fixed at **keyboardHeightChange**, indicating the keyboard height change event.| +| callback | Callbacknumber> | Yes | Callback used to return the information. | **Example** @@ -1482,16 +1480,14 @@ off(type: 'keyboardHeightChange', callback?: Callback<number>): void Disables listening for keyboard height changes. -This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. - **System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** - | Name | Type | Mandatory| Description | - | -------- | ---------------------- | ---- | ------------------------------------------------------------ | - | type | string | Yes | Type of event to listen for. The value is fixed at **keyboardHeightChange**, indicating the keyboard height change event.| - | callback | Callback<number> | No | Callback used to return the information. | +| Name | Type | Mandatory| Description | +| -------- | ---------------------- | ---- | ------------------------------------------------------------ | +| type | string | Yes | Type of event to listen for. The value is fixed at **keyboardHeightChange**, indicating the keyboard height change event.| +| callback | Callback<number> | No | Callback used to return the information. | **Example** @@ -1510,9 +1506,9 @@ Checks whether this window supports the wide color gamut mode. This API uses an **Parameters** - | Name | Type | Mandatory| Description | - | -------- | ---------------------------- | ---- | -------------------------------- | - | callback | AsyncCallback<boolean> | Yes | Callback used to return whether the wide color gamut mode is supported.| +| Name | Type | Mandatory| Description | +| -------- | ---------------------------- | ---- | -------------------------------- | +| callback | AsyncCallback<boolean> | Yes | Callback used to return whether the wide color gamut mode is supported.| **Example** @@ -1536,9 +1532,9 @@ Checks whether this window supports the wide color gamut mode. This API uses a p **Return value** - | Type | Description | - | ---------------------- | ------------------------------------------------------------ | - | Promise<boolean> | Promise used to return whether the wide color gamut mode is supported.| +| Type | Description | +| ---------------------- | ------------------------------------------------------------ | +| Promise<boolean> | Promise used to return whether the wide color gamut mode is supported.| **Example** @@ -1561,10 +1557,10 @@ Sets this window to the wide or default color gamut mode. This API uses an async **Parameters** - | Name | Type | Mandatory| Description | - | ---------- | ------------------------- | ---- | ------------ | - | colorSpace | [ColorSpace](#colorspace) | Yes | Color gamut mode.| - | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | +| Name | Type | Mandatory| Description | +| ---------- | ------------------------- | ---- | ------------ | +| colorSpace | [ColorSpace](#colorspace) | Yes | Color gamut mode.| +| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | **Example** @@ -1588,15 +1584,15 @@ Sets this window to the wide or default color gamut mode. This API uses a promis **Parameters** - | Name | Type | Mandatory| Description | - | ---------- | ------------------------- | ---- | ------------ | - | colorSpace | [ColorSpace](#colorspace) | Yes | Color gamut mode.| +| Name | Type | Mandatory| Description | +| ---------- | ------------------------- | ---- | ------------ | +| colorSpace | [ColorSpace](#colorspace) | Yes | Color gamut mode.| **Return value** - | Type | Description | - | ------------------- | ----------------------------------------------- | - | Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ----------------------------------------------- | +| Promise<void> | Promise used to return the execution result.| **Example** @@ -1619,9 +1615,9 @@ Obtains the color gamut mode of this window. This API uses an asynchronous callb **Parameters** - | Name | Type | Mandatory| Description | - | -------- | ---------------------------------------------- | ---- | -------------------------- | - | callback | AsyncCallback<[ColorSpace](#colorspace)> | Yes | Callback used to return the color gamut mode obtained.| +| Name | Type | Mandatory| Description | +| -------- | ---------------------------------------------- | ---- | -------------------------- | +| callback | AsyncCallback<[ColorSpace](#colorspace)> | Yes | Callback used to return the color gamut mode obtained.| **Example** @@ -1645,9 +1641,9 @@ Obtains the color gamut mode of this window. This API uses a promise to return t **Return value** - | Type | Description | - | ---------------------------------------- | ----------------------------------------- | - | Promise<[ColorSpace](#colorspace)> | Promise used to return the color gamut mode obtained.| +| Type | Description | +| ---------------------------------------- | ----------------------------------------- | +| Promise<[ColorSpace](#colorspace)> | Promise used to return the color gamut mode obtained.| **Example** @@ -1666,16 +1662,14 @@ setBackgroundColor(color: string, callback: AsyncCallback<void>): void Sets the background color for this window. This API uses an asynchronous callback to return the result. -This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. - **System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** - | Name | Type | Mandatory| Description | - | -------- | ------------------------- | ---- | ------------------------------------------------------------ | - | color | string | Yes | Background color to set. The color is a hexadecimal value, for example, #00FF00 or #FF00FF00.| - | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | ------------------------------------------------------------ | +| color | string | Yes | Background color to set. The color is a hexadecimal value, for example, #00FF00 or #FF00FF00.| +| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | **Example** @@ -1696,21 +1690,19 @@ setBackgroundColor(color: string): Promise<void> Sets the background color for this window. This API uses a promise to return the result. -This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. - **System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | ------------------------------------------------------------ | - | color | string | Yes | Background color to set. The color is a hexadecimal value, for example, #00FF00 or #FF00FF00.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------------------------------------------------------------ | +| color | string | Yes | Background color to set. The color is a hexadecimal value, for example, #00FF00 or #FF00FF00.| **Return value** - | Type | Description | - | ------------------- | ----------------------------------------------- | - | Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ----------------------------------------------- | +| Promise<void> | Promise used to return the execution result.| **Example** @@ -1730,16 +1722,14 @@ setBrightness(brightness: number, callback: AsyncCallback<void>): void Sets the screen brightness for this window. This API uses an asynchronous callback to return the result. -This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. - **System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** - | Name | Type | Mandatory| Description | - | ---------- | ------------------------- | ---- | ------------------------------------ | - | brightness | number | Yes | Brightness to set, which ranges from 0 to 1. The value **1** indicates the brightest.| - | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | +| Name | Type | Mandatory| Description | +| ---------- | ------------------------- | ---- | ------------------------------------ | +| brightness | number | Yes | Brightness to set, which ranges from 0 to 1. The value **1** indicates the brightest.| +| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | **Example** @@ -1760,21 +1750,19 @@ setBrightness(brightness: number): Promise<void> Sets the screen brightness for this window. This API uses a promise to return the result. -This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. - **System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** - | Name | Type | Mandatory| Description | - | ---------- | ------ | ---- | ------------------------------------ | - | brightness | number | Yes | Brightness to set, which ranges from 0 to 1. The value **1** indicates the brightest.| +| Name | Type | Mandatory| Description | +| ---------- | ------ | ---- | ------------------------------------ | +| brightness | number | Yes | Brightness to set, which ranges from 0 to 1. The value **1** indicates the brightest.| **Return value** - | Type | Description | - | ------------------- | ----------------------------------------------- | - | Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ----------------------------------------------- | +| Promise<void> | Promise used to return the execution result.| **Example** @@ -1788,84 +1776,20 @@ This API is defined but not implemented in OpenHarmony 3.1 Release. It will be a }); ``` -### setDimBehind7+ - -setDimBehind(dimBehindValue: number, callback: AsyncCallback<void>): void - -Sets the dimness of the window that is not on top. This API uses an asynchronous callback to return the result. - -This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. - -**System capability**: SystemCapability.WindowManager.WindowManager.Core - -**Parameters** - - | Name | Type | Mandatory| Description | - | -------------- | ------------------------- | ---- | -------------------------------------------------- | - | dimBehindValue | number | Yes | Dimness of the window to set. The value ranges from 0 to 1. The value **1** indicates the dimmest.| - | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | - -**Example** - - ```js - windowClass.setDimBehind(0.5, (err, data) => { - if (err.code) { - console.error('Failed to set the dimness. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in setting the dimness. Data:' + JSON.stringify(data)); - }); - ``` - -### setDimBehind7+ - -setDimBehind(dimBehindValue: number): Promise<void> - -Sets the dimness of the window that is not on top. This API uses a promise to return the result. - -This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. - -**System capability**: SystemCapability.WindowManager.WindowManager.Core - -**Parameters** - - | Name | Type | Mandatory| Description | - | -------------- | ------ | ---- | -------------------------------------------------- | - | dimBehindValue | number | Yes | Dimness of the window to set. The value ranges from 0 to 1. The value **1** indicates the dimmest.| - -**Return value** - - | Type | Description | - | ------------------- | ----------------------------------------------- | - | Promise<void> | Promise used to return the execution result.| - -**Example** - - ```js - let promise = windowClass.setDimBehind(0.5); - promise.then((data)=> { - console.info('Succeeded in setting the dimness. Data: ' + JSON.stringify(data)) - }).catch((err)=>{ - console.error('Failed to set the dimness. Cause: ' + JSON.stringify(err)); - }); - ``` - ### setFocusable7+ setFocusable(isFocusable: boolean, callback: AsyncCallback<void>): void Sets whether this window can gain focus. This API uses an asynchronous callback to return the result. -This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. - **System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** - | Name | Type | Mandatory| Description | - | ----------- | ------------------------- | ---- | ---------------------------- | - | isFocusable | boolean | Yes | Whether the window can gain focus.| - | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | +| Name | Type | Mandatory| Description | +| ----------- | ------------------------- | ---- | ---------------------------- | +| isFocusable | boolean | Yes | Whether the window can gain focus.| +| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | **Example** @@ -1886,21 +1810,19 @@ setFocusable(isFocusable: boolean): Promise<void> Sets whether this window can gain focus. This API uses a promise to return the result. -This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. - **System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** - | Name | Type | Mandatory| Description | - | ----------- | ------- | ---- | ---------------------------- | - | isFocusable | boolean | Yes | Whether the window can gain focus.| +| Name | Type | Mandatory| Description | +| ----------- | ------- | ---- | ---------------------------- | +| isFocusable | boolean | Yes | Whether the window can gain focus.| **Return value** - | Type | Description | - | ------------------- | ----------------------------------------------- | - | Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ----------------------------------------------- | +| Promise<void> | Promise used to return the execution result.| **Example** @@ -1920,16 +1842,14 @@ setKeepScreenOn(isKeepScreenOn: boolean, callback: AsyncCallback<void>): v Sets whether to keep the screen always on. This API uses an asynchronous callback to return the result. -This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. - **System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** - | Name | Type | Mandatory| Description | - | -------------- | ------------------------- | ---- | ------------------------ | - | isKeepScreenOn | boolean | Yes | Whether to keep the screen always on.| - | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | +| Name | Type | Mandatory| Description | +| -------------- | ------------------------- | ---- | ------------------------ | +| isKeepScreenOn | boolean | Yes | Whether to keep the screen always on.| +| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | **Example** @@ -1950,21 +1870,19 @@ setKeepScreenOn(isKeepScreenOn: boolean): Promise<void> Sets whether to keep the screen always on. This API uses a promise to return the result. -This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. - **System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** - | Name | Type | Mandatory| Description | - | -------------- | ------- | ---- | ------------------------ | - | isKeepScreenOn | boolean | Yes | Whether to keep the screen always on.| +| Name | Type | Mandatory| Description | +| -------------- | ------- | ---- | ------------------------ | +| isKeepScreenOn | boolean | Yes | Whether to keep the screen always on.| **Return value** - | Type | Description | - | ------------------- | ----------------------------------------------- | - | Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ----------------------------------------------- | +| Promise<void> | Promise used to return the execution result.| **Example** @@ -1978,84 +1896,20 @@ This API is defined but not implemented in OpenHarmony 3.1 Release. It will be a }); ``` -### setOutsideTouchable7+ - -setOutsideTouchable(touchable: boolean, callback: AsyncCallback<void>): void - -Sets whether the area outside the subwindow is touchable. This API uses an asynchronous callback to return the result. - -This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. - -**System capability**: SystemCapability.WindowManager.WindowManager.Core - -**Parameters** - - | Name | Type | Mandatory| Description | - | --------- | ------------------------- | ---- | ---------------- | - | touchable | boolean | Yes | Whether the area outside the subwindow is touchable. The value **true** means that such an area is touchable, and **false** means the opposite.| - | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | - -**Example** - - ```js - windowClass.setOutsideTouchable(true, (err, data) => { - if (err.code) { - console.error('Failed to set the area to be touchable. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in setting the area to be touchable. Data: ' + JSON.stringify(data)) - }) - ``` - -### setOutsideTouchable7+ - -setOutsideTouchable(touchable: boolean): Promise<void> - -Sets whether the area outside the subwindow is touchable. This API uses a promise to return the result. - -This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. - -**System capability**: SystemCapability.WindowManager.WindowManager.Core - -**Parameters** - - | Name | Type | Mandatory| Description | - | --------- | ------- | ---- | ---------------- | - | touchable | boolean | Yes | Whether the area outside the subwindow is touchable. The value **true** means that such an area is touchable, and **false** means the opposite.| - -**Return value** - - | Type | Description | - | ------------------- | ----------------------------------------------- | - | Promise<void> | Promise used to return the execution result.| - -**Example** - - ```js - let promise = windowClass.setOutsideTouchable(true); - promise.then((data)=> { - console.info('Succeeded in setting the area to be touchable. Data: ' + JSON.stringify(data)) - }).catch((err)=>{ - console.error('Failed to set the area to be touchable. Cause: ' + JSON.stringify(err)); - }); - ``` - ### setPrivacyMode7+ setPrivacyMode(isPrivacyMode: boolean, callback: AsyncCallback<void>): void Sets whether this window is in privacy mode. This API uses an asynchronous callback to return the result. -This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. - **System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** - | Name | Type | Mandatory| Description | - | ------------- | ------------------------- | ---- | -------------------- | - | isPrivacyMode | boolean | Yes | Whether the window is in privacy mode.| - | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | +| Name | Type | Mandatory| Description | +| ------------- | ------------------------- | ---- | -------------------- | +| isPrivacyMode | boolean | Yes | Whether the window is in privacy mode.| +| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | **Example** @@ -2077,21 +1931,19 @@ setPrivacyMode(isPrivacyMode: boolean): Promise<void> Sets whether this window is in privacy mode. This API uses a promise to return the result. -This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. - **System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** - | Name | Type | Mandatory| Description | - | ------------- | ------- | ---- | -------------------- | - | isPrivacyMode | boolean | Yes | Whether the window is in privacy mode.| +| Name | Type | Mandatory| Description | +| ------------- | ------- | ---- | -------------------- | +| isPrivacyMode | boolean | Yes | Whether the window is in privacy mode.| **Return value** - | Type | Description | - | ------------------- | ----------------------------------------------- | - | Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ----------------------------------------------- | +| Promise<void> | Promise used to return the execution result.| **Example** @@ -2111,16 +1963,14 @@ setTouchable(isTouchable: boolean, callback: AsyncCallback<void>): void Sets whether this window is touchable. This API uses an asynchronous callback to return the result. -This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. - **System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** - | Name | Type | Mandatory| Description | - | ----------- | ------------------------- | ---- | -------------------- | - | isTouchable | boolean | Yes | Whether the window is touchable.| - | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | +| Name | Type | Mandatory| Description | +| ----------- | ------------------------- | ---- | -------------------- | +| isTouchable | boolean | Yes | Whether the window is touchable.| +| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | **Example** @@ -2142,21 +1992,19 @@ setTouchable(isTouchable: boolean): Promise<void> Sets whether this window is touchable. This API uses a promise to return the result. -This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. - **System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** - | Name | Type | Mandatory| Description | - | ----------- | ------- | ---- | -------------------- | - | isTouchable | boolean | Yes | Whether the window is touchable.| +| Name | Type | Mandatory| Description | +| ----------- | ------- | ---- | -------------------- | +| isTouchable | boolean | Yes | Whether the window is touchable.| **Return value** - | Type | Description | - | ------------------- | ----------------------------------------------- | - | Promise<void> | Promise used to return the execution result.| +| Type | Description | +| ------------------- | ----------------------------------------------- | +| Promise<void> | Promise used to return the execution result.| **Example** @@ -2197,9 +2045,9 @@ Obtains the main window of this window stage. This API uses a promise to return **Return value** - | Type | Description | - | -------------------------------- | ---------------------------------------------------------- | - | Promise<[Window](#window)> | Promise used to return the main window.| +| Type | Description | +| -------------------------------- | ---------------------------------------------------------- | +| Promise<[Window](#window)> | Promise used to return the main window.| **Example** @@ -2229,9 +2077,9 @@ Obtains the main window of this window stage. This API uses an asynchronous call **Parameters** - | Name | Type | Mandatory| Description | - | -------- | -------------------------------------- | ---- | --------------------------------------- | - | callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the main window.| +| Name | Type | Mandatory| Description | +| -------- | -------------------------------------- | ---- | --------------------------------------- | +| callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the main window.| **Example** @@ -2262,15 +2110,15 @@ Creates a subwindow for this window stage. This API uses a promise to return the **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | -------------- | - | name | String | Yes | Name of the subwindow.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | -------------- | +| name | String | Yes | Name of the subwindow.| **Return value** - | Type | Description | - | -------------------------------- | ------------------------------------------------- | - | Promise<[Window](#window)> | Promise used to return the subwindow created.| +| Type | Description | +| -------------------------------- | ------------------------------------------------- | +| Promise<[Window](#window)> | Promise used to return the subwindow created.| **Example** @@ -2300,10 +2148,10 @@ Creates a subwindow for this window stage. This API uses an asynchronous callbac **Parameters** - | Name | Type | Mandatory| Description | - | -------- | -------------------------------------- | ---- | ------------------------------ | - | name | String | Yes | Name of the subwindow. | - | callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the subwindow created.| +| Name | Type | Mandatory| Description | +| -------- | -------------------------------------- | ---- | ------------------------------ | +| name | String | Yes | Name of the subwindow. | +| callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the subwindow created.| **Example** @@ -2335,9 +2183,9 @@ Obtains all the subwindows of this window stage. This API uses a promise to retu **Return value** - | Type | Description | - | --------------------------------------------- | ------------------------------------------------------------ | - | Promise<Array<[Window](#window)>> | Promise used to return all the subwindows.| +| Type | Description | +| --------------------------------------------- | ------------------------------------------------------------ | +| Promise<Array<[Window](#window)>> | Promise used to return all the subwindows.| **Example** @@ -2367,9 +2215,9 @@ Obtains all the subwindows of this window stage. This API uses an asynchronous c **Parameters** - | Name | Type | Mandatory| Description | - | -------- | --------------------------------------------------- | ---- | ------------------------------------------- | - | callback | AsyncCallback<Array<[Window](#window)>> | Yes | Callback used to return all the subwindows.| +| Name | Type | Mandatory| Description | +| -------- | --------------------------------------------------- | ---- | ------------------------------------------- | +| callback | AsyncCallback<Array<[Window](#window)>> | Yes | Callback used to return all the subwindows.| **Example** @@ -2400,10 +2248,10 @@ Loads content to this window stage. This API uses an asynchronous callback to re **Parameters** - | Name | Type | Mandatory| Description | - | -------- | ------------------------- | ---- | -------------------- | - | path | string | Yes | Path of the page from which the content will be loaded.| - | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | -------------------- | +| path | string | Yes | Path of the page from which the content will be loaded.| +| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | **Example** @@ -2432,10 +2280,10 @@ Enables listening for window stage lifecycle changes. **Parameters** - | Name | Type | Mandatory| Description | - | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | - | type | string | Yes | Type of event to listen for. The value is fixed at **windowStageEvent**, indicating the window stage lifecycle change event.| - | callback | Callback<[WindowStageEventType](#windowstageeventtype9)> | Yes | Callback used to return the information. | +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | string | Yes | Type of event to listen for. The value is fixed at **windowStageEvent**, indicating the window stage lifecycle change event.| +| callback | Callback<[WindowStageEventType](#windowstageeventtype9)> | Yes | Callback used to return the information. | **Example** @@ -2461,10 +2309,10 @@ Disables listening for window stage lifecycle changes. **Parameters** - | Name | Type | Mandatory| Description | - | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | - | type | string | Yes | Type of event to listen for. The value is fixed at **windowStageEvent**, indicating the window stage lifecycle change event.| - | callback | Callback<[WindowStageEventType](#windowstageeventtype9)> | No | Callback used to return the information. | +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | string | Yes | Type of event to listen for. The value is fixed at **windowStageEvent**, indicating the window stage lifecycle change event.| +| callback | Callback<[WindowStageEventType](#windowstageeventtype9)> | No | Callback used to return the information. | **Example** diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-textarea.md b/en/application-dev/reference/arkui-ts/ts-basic-components-textarea.md index f686f9a01011f7afb704d3f10d5fadc7bd521ee3..18351055d42a9f1a42085dbe5afcfd4b2ba70b83 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-textarea.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-textarea.md @@ -1,8 +1,8 @@ # TextArea -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** -> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. +> The **<TextArea>** component provides multi-line text input. @@ -90,7 +90,7 @@ Sets the position of the caret. ``` @Entry @Component -struct TextAreaExample2 { +struct TextAreaExample1 { @State text: string = '' build() { Column() { @@ -126,7 +126,7 @@ struct TextAreaExample2 { ``` @Entry @Component -struct TextAreaTest { +struct TextAreaExample2 { controller: TextAreaController = new TextAreaController() build() { Column() { diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-textinput.md b/en/application-dev/reference/arkui-ts/ts-basic-components-textinput.md index 591d688e88b6869b429efd51f6a5348f9156e68d..a10e217459ce850706675e0a7a9f1e3dcb48f415 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-textinput.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-textinput.md @@ -1,7 +1,6 @@ # TextInput - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. @@ -61,13 +60,21 @@ In addition to universal attributes, the following attributes are supported. | InputType.Number | Digit input mode. | -### TextInputController8+ - -Implements the controller of the **<TextInput>** component. +## Events | Name | Description | | -------- | -------- | -| caretPosition(value: number):void | Position of the input cursor.
**value**: indicates the length from the start of the string to the position where the input cursor is located. | +| onChange(value: string) => void | Triggered when the input changes. | +| onSubmit(callback: (enterKey: EnterKeyType) => void) | Triggered when the Enter key on the physical or soft keyboard is pressed. | +| onEditChanged(callback: (isEditing: boolean) => void)(deprecated) | Triggered when the input status changes. | +| onEditChange(callback: (isEditing: boolean) => void) 8+ | Triggered when the input status changes. | +| onCopy8+(callback:(value: string) => void) | Triggered when the copy button on the pasteboard, which displays when the text box is long pressed, is clicked.
**value**: text to be copied. | +| onCut8+(callback:(value: string) => void) | Triggered when the cut button on the pasteboard, which displays when the text box is long pressed, is clicked.
**value**: text to be cut. | +| onPaste8+(callback:(value: string) => void) | Triggered when the paste button on the pasteboard, which displays when the text box is long pressed, is clicked.
**value**: text to be pasted. | + +### TextInputController8+ + +Implements the controller of the **<TextInput>** component. ### Objects to Import @@ -78,7 +85,7 @@ controller: TextInputController = new TextInputController() ``` -### controller.createPosition +#### caretPosition caretPosition(value: number): void @@ -90,18 +97,6 @@ Sets the cursor in a specified position. | value | number | Yes | - | Position of the input cursor.
**value**: indicates the length from the start of the string to the position where the input cursor is located. | -## Events - -| Name | Description | -| -------- | -------- | -| onChange(value: string) => void | Triggered when the input changes. | -| onSubmit(callback: (enterKey: EnterKeyType) => void) | Triggered when the Enter key on the physical or soft keyboard is pressed. | -| onEditChanged(callback: (isEditing: boolean) => void)(deprecated) | Triggered when the input status changes. | -| onEditChange(callback: (isEditing: boolean) => void) 8+ | Triggered when the input status changes. | -| onCopy8+(callback:(value: string) => void) | Triggered when the copy button on the pasteboard, which displays when the text box is long pressed, is clicked.
**value**: text to be copied. | -| onCut8+(callback:(value: string) => void) | Triggered when the cut button on the pasteboard, which displays when the text box is long pressed, is clicked.
**value**: text to be cut. | -| onPaste8+(callback:(value: string) => void) | Triggered when the paste button on the pasteboard, which displays when the text box is long pressed, is clicked.
**value**: text to be pasted. | - ## Example @@ -112,7 +107,7 @@ Sets the cursor in a specified position. ``` @Entry @Component -struct TextAreaExample2 { +struct TextInputExample1 { @State text: string = '' build() { @@ -147,7 +142,7 @@ struct TextAreaExample2 { ``` @Entry @Component -struct TextInputTest { +struct TextInputExample2 { @State text: string = '' controller: TextInputController = new TextInputController() build() { diff --git a/en/application-dev/reference/arkui-ts/ts-container-flex.md b/en/application-dev/reference/arkui-ts/ts-container-flex.md index 8e47369ccfe0454e165416dc69b84206d3bb8465..f3c451f768755ab02dffca81937df95b063ddc42 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-flex.md +++ b/en/application-dev/reference/arkui-ts/ts-container-flex.md @@ -1,11 +1,11 @@ # Flex -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The **<Flex>** component allows for an elastic layout. +The **\** component allows for an elastic layout. ## Required Permissions @@ -22,46 +22,45 @@ This component can contain child components. Flex(options?: { direction?: FlexDirection, wrap?: FlexWrap, justifyContent?: FlexAlign, alignItems?: ItemAlign, alignContent?: FlexAlign }) -Creates a standard **<Flex>** component. +Creates a standard **\** component. - Parameters - | Name | Type | Mandatory | Default Value | Description | + | Name | Type | Mandatory | Default Value | Description | | -------- | -------- | -------- | -------- | -------- | - | direction | FlexDirection | No | FlexDirection.Row | Direction in which child components are arranged in the **<Flex>** component, that is, the direction of the main axis. | - | wrap | FlexWrap | No | FlexWrap.NoWrap | Whether the **<Flex>** component has a single line or multiple lines. | - | justifyContent | FlexAlign | No | FlexAlign.Start | Alignment mode of the child components in the **<Flex>** component along the main axis. | - | alignItems | [ItemAlign](ts-appendix-enums.md#itemalign-enums) | No | ItemAlign.Stretch | Alignment mode of the child components in the **<Flex>** component along the cross axis. | - | alignContent | FlexAlign | No | FlexAlign.Start | Alignment mode of the child components in a multi-line **<Flex>** component along the cross axis. This parameter is valid only when **wrap** is set to **Wrap** or **WrapReverse**. | + | direction | FlexDirection | No | FlexDirection.Row | Direction in which child components are arranged in the **\** component, that is, the direction of the main axis. | + | wrap | FlexWrap | No | FlexWrap.NoWrap | Whether the **\** component has a single line or multiple lines. | + | justifyContent | FlexAlign | No | FlexAlign.Start | Alignment mode of the child components in the **\** component along the main axis. | + | alignItems | [ItemAlign](ts-appendix-enums.md#itemalign-enums) | No | ItemAlign.Stretch | Alignment mode of the child components in the **\** component along the cross axis. | + | alignContent | FlexAlign | No | FlexAlign.Start | Alignment mode of the child components in a multi-line **\** component along the cross axis. This parameter is valid only when **wrap** is set to **Wrap** or **WrapReverse**. | - FlexDirection enums - | Name | Description | + | Name | Description | | -------- | -------- | - | Row | The child components are arranged in the same direction as the main axis runs along the rows. | - | RowReverse | The child components are arranged opposite to the **Row** direction. | - | Column | The child components are arranged in the same direction as the main axis runs down the columns. | - | ColumnReverse | The child components are arranged opposite to the **Column** direction. | + | Row | The child components are arranged in the same direction as the main axis runs along the rows. | + | RowReverse | The child components are arranged opposite to the **Row** direction. | + | Column | The child components are arranged in the same direction as the main axis runs down the columns. | + | ColumnReverse | The child components are arranged opposite to the **Column** direction. | - FlexWrap enums - | Name | Description | + | Name | Description | | -------- | -------- | - | NoWrap | The child components in the **<Flex>** component are arranged in a single line, and they may overflow. | - | Wrap | The child components in the **<Flex>** component are arranged in multiple lines, and they may overflow. | - | WrapReverse | The child components in the **<Flex>** component are reversely arranged in multiple lines, and they may overflow. | + | NoWrap | The child components in the **<Flex>** component are arranged in a single line, and they may overflow. | + | Wrap | The child components in the **<Flex>** component are arranged in multiple lines, and they may overflow. | + | WrapReverse | The child components in the **<Flex>** component are reversely arranged in multiple lines, and they may overflow. | - FlexAlign enums - | Name | Description | + | Name | Description | | -------- | -------- | - | Start | The child components are aligned with the start edge of the main axis. The first component is aligned with the main-start, and subsequent components are aligned with the previous one. | - | Center | The child components are aligned in the center of the main axis. The space between the first component and the main-start is the same as that between the last component and the main-end. | - | End | The child components are aligned with the end edge of the main axis. The last component is aligned with the main-end, and other components are aligned with the next one. | - | SpaceBetween | The child components are evenly distributed along the main axis. The first component is aligned with the main-start, the last component is aligned with the main-end, and the remaining components are distributed so that the space between any two adjacent components is the same. | - | SpaceAround | The child components are evenly distributed along the main axis, with a half-size space on either end. The space between any two adjacent components is the same. The space between the first component and main-start, and that between the last component and cross-main are both half the size of the space between two adjacent components. | - | SpaceEvenly | The child components are equally distributed along the main axis. The space between the first component and main-start, the space between the last component and main-end, and the space between two adjacent components are the same. | + | Start | The child components are aligned with the start edge of the main axis. The first component is aligned with the main-start, and subsequent components are aligned with the previous one. | + | Center | The child components are aligned in the center of the main axis. The space between the first component and the main-start is the same as that between the last component and the main-end. | + | End | The child components are aligned with the end edge of the main axis. The last component is aligned with the main-end, and other components are aligned with the next one. | + | SpaceBetween | The child components are evenly distributed along the main axis. The first component is aligned with the main-start, the last component is aligned with the main-end, and the remaining components are distributed so that the space between any two adjacent components is the same. | + | SpaceAround | The child components are evenly distributed along the main axis, with a half-size space on either end. The space between any two adjacent components is the same. The space between the first component and main-start, and that between the last component and cross-main are both half the size of the space between two adjacent components. | + | SpaceEvenly | The child components are equally distributed along the main axis. The space between the first component and main-start, the space between the last component and main-end, and the space between two adjacent components are the same. | ## Example - ``` // Example 01 @Entry diff --git a/en/application-dev/ui/ts-component-based-builder.md b/en/application-dev/ui/ts-component-based-builder.md index 94e75620e5a4d9c1f24cb7c0325d6f852017f797..a07b244ffdc2bd9105102058e6881b14289fdf34 100644 --- a/en/application-dev/ui/ts-component-based-builder.md +++ b/en/application-dev/ui/ts-component-based-builder.md @@ -1,8 +1,7 @@ # @Builder -The @Builder decorated method is used to define the declarative UI description of a component and quickly generate multiple layouts in a custom component. The functionality and syntax of the @Builder decorator are the same as those of the [build Function](ts-function-build.md). - +The **@Builder** decorated method is used to define the declarative UI description of a component and quickly generate multiple layouts in a custom component. The functionality and syntax of the **@Builder** decorator are the same as those of the [build Function](ts-function-build.md). ``` @@ -42,30 +41,29 @@ struct CompA { } } ``` - -## @BuilderParam8+ - -The @BuilderParam decorator is used to modify the function type attributes (for example, @BuilderParam content: () => any) in a custom component. When the custom component is initialized, the attributes modified by the @BuilderParam decorator must be assigned values. +## @BuilderParam8+ +The **@BuilderParam** decorator is used to modify the function type attributes (for example, `@BuilderParam content: () => any;`) in a custom component. When the custom component is initialized, the attributes modified by the **@BuilderParam** decorator must be assigned values. ### Background -In certain circumstances, you may need to add a specific function, such as a click-to-jump action, to a custom component. However, embedding an event method directly inside of the component can add the function to all places where the component is initialized. This is where the @BuilderParam decorator come into the picture. When initializing a custom component, you can assign a @Builder decorated method to the @BuilderParam decorated attribute, thereby adding the specific function to the custom component. +In certain circumstances, you may need to add a specific function, such as a click-to-jump action, to a custom component. However, embedding an event method directly inside of the component will add the function to all places where the component is initialized. This is where the **@BuilderParam** decorator comes into the picture. When initializing a custom component, you can assign a **@Builder** decorated method to the **@BuilderParam** decorated attribute, thereby adding the specific function to the custom component. ### Component Initialization Through Parameters - -When initializing a custom component through parameters, assign a @Builder decorated method to the @BuilderParam decorated attribute —content, and call the value of content in the custom component. +When initializing a custom component through parameters, assign a **@Builder** decorated method to the **@BuilderParam** decorated attribute — **content**, and call the value of **content** in the custom component. If no parameter is passed when assigning a value to the **@BuilderParam** decorated attribute (for example, `content: this.specificParam`), define the type of the attribute as a function without a return value (for example, `@BuilderParam content: () => void`). If any parameter is passed when assigning a value to the **@BuilderParam** decorated attribute (for example, `callContent: this.specificParam1("111")`), define the type of the attribute as `any` (for example,`@BuilderParam callContent: any;`). ``` @Component struct CustomContainer { header: string = ""; - @BuilderParam content: () => any; + @BuilderParam noParam: () => void; + @BuilderParam withParam: any; footer: string = ""; build() { Column() { Text(this.header) .fontSize(50) - this.content() + this.noParam() + this.withParam() Text(this.footer) .fontSize(50) } @@ -75,7 +73,12 @@ struct CustomContainer { @Entry @Component struct CustomContainerUser { - @Builder specificParam(label: string) { + @Builder specificNoParam() { + Column() { + Text("noParam").fontSize(50) + } + } + @Builder SpecificWithParam(label: string) { Column() { Text(label).fontSize(50) } @@ -85,25 +88,23 @@ struct CustomContainerUser { Column() { CustomContainer({ header: "Header", - content: this.specificParam("111") + noParam: this.specificNoParam, + withParam: this.SpecificWithParam("WithParam"), footer: "Footer", }) } } } ``` - ### Component Initialization Through Trailing Closure +In a custom component, use the **@BuilderParam** decorated attribute to receive a trailing closure. When the custom component is initialized, the component name is followed by a pair of braces ({}) to form a trailing closure (`CustomComponent(){}`). You can consider a trailing closure as a container and add content to it. For example, you can add a component (`{Column(){Text("content")}`) to a trailing closure. The syntax of the closure is the same as that of [build](../ui/ts-function-build.md). In this scenario, the custom component has one and only one **@BuilderParam** decorated attribute. -In a custom component, use the @BuilderParam decorated attribute to receive a trailing closure. When the custom component is initialized, the component name is followed by a pair of braces ({}) to form a trailing closure (CustomComponent(){}). You can consider a trailing closure as a container and add content to it. For example, you can add a component ({Column(){Text("content")}) to the closure. The syntax of the closure is the same as that of [build](ts-function-build.md). In this scenario, the custom component has one and only one @BuilderParam decorated attribute. - -Example: Add a <Column> component and a click event to the closure, and call the specificParam method decorated by @Builder in the new <Column> component. After the <Column> component is clicked, the value of the component's header attribute will be changed to changeHeader. In addition, when the component is initialized, the content of the trailing closure will be assigned to the closer attribute decorated by @BuilderParam. - +Example: Add a **\** component and a click event to the closure, and call the **specificParam** method decorated by **@Builder** in the new **\** component. After the **\** component is clicked, the value of the component's `header` attribute will change to `changeHeader`. In addition, when the component is initialized, the content of the trailing closure will be assigned to the `closer` attribute decorated by **@BuilderParam**. ``` @Component struct CustomContainer { header: string = ""; - @BuilderParam closer: () => any; + @BuilderParam closer: () => void; build() { Column() { Text(this.header) diff --git a/en/application-dev/ui/ui-ts-creating-simple-page.md b/en/application-dev/ui/ui-ts-creating-simple-page.md index 9d7054cc4dc17ee2e869f66e0711524f83e6fd93..4e9ee4b92152eade3066c4a79cb328cf8b998a57 100644 --- a/en/application-dev/ui/ui-ts-creating-simple-page.md +++ b/en/application-dev/ui/ui-ts-creating-simple-page.md @@ -1,13 +1,13 @@ # Creating a Simple Page -In this section, we will develop an infographic food details page, by building custom components through the container components <Stack> and <Flex> as well as basic components <Image> and <Text>. +In this section, we will develop an infographic food details page, by building custom components through the container components **\** and **\** as well as basic components **\** and **\**. ## Building the Stack Layout 1. Create a food name. - Delete the code of the build method in the project template, create a <Stack> component, and place the <Text> component in the braces of the <Stack> component so that the <Text> component becomes a child component of the <Stack> component. A <Stack> component consists of one or more child components. The latter child component overwrites the former one. + Delete the code of the build method in the project template, create a <Stack> component, and place the **\** component in the braces of the **\** component so that the <Text> component becomes a child component of the <Stack> component. A **\** component consists of one or more child components. The latter child component overwrites the former one. ``` @Entry @@ -26,7 +26,7 @@ In this section, we will develop an infographic food details page, by building c ![en-us_image_0000001222967780](figures/en-us_image_0000001222967780.png) 2. Display food pictures. - Create an <Image> component and specify a URL for it. The <Image> and <Text> components are mandatory. To display the <Text> component above the <Image> component, you need to declare the <Image> component first. Image resources are stored in the rawfile folder in resources. When referencing the resources in the rawfile folder, use the `"$rawfile('filename')"` format, where filename indicates the relative path of the file in the rawfile folder. Currently, `$rawfile` only allows the <Image> component to reference image resources. + Create an **\** component and specify a URL for it. The **\** and **\** components are mandatory. To display the **\** component above the **\** component, you need to declare the **\** component first. Image resources are stored in the **rawfile** folder in **resources**. When referencing the resources in the **rawfile** folder, use the `"$rawfile('filename')"` format, where filename indicates the relative path of the file in the **rawfile** folder. Currently, `$rawfile` only allows the **\** component to reference image resources. ``` @Entry @@ -137,9 +137,9 @@ In this section, we will develop an infographic food details page, by building c ![en-us_image_0000001222967772](figures/en-us_image_0000001222967772.png) -7. Adjust the left and bottom margin of the <Text> component. Margin is a shorthand attribute. You can specify the margins of the four edges in a unified manner or separately. The configuration method is as follows: - 1. When the parameter is set to Length, the outer margins of the four edges are specified. For example, **margin(20)** indicates that the outer margins of the top, right, bottom, and left edges are all 20. - 2. **{top?: Length, right?: Length, bottom?: Length, left?:Length}** specifies the margins of the four edges. For example, **margin({ left: 26, bottom: 17.4 })** indicates that the left margin is 26 and the bottom margin is 17.4. +7. Adjust the left and bottom margin of the **\** component. **Margin** is a shorthand attribute. You can specify the margins of the four edges in a unified manner or separately. The configuration method is as follows: + 1. To set the margins of the four edges in a unified manner, use the **Margin(Length)** format. For example, **margin(20)** indicates that the outer margins of the top, right, bottom, and left edges are all 20. + 2. To set the margins of the four edges separately, use the **{top?: Length, right?: Length, bottom?: Length, left?:Length}** format. For example, **margin({ left: 26, bottom: 17.4 })** indicates that the left margin is 26 and the bottom margin is 17.4. ``` @@ -163,7 +163,8 @@ In this section, we will develop an infographic food details page, by building c ![en-us_image_0000001222967776](figures/en-us_image_0000001222967776.png) -8. Adjust the structure between components and semanticize component names. Create the FoodDetail page entry component, create a column in **FoodDetail**, and set the alignment to **alignItems(HorizontalAlign.Center)**. Change the name of the MyComponent component to FoodImageDisplay, which is a child component of the FoodDetail component. +8. Adjust the structure between components and semanticize component names. Create the FoodDetail page entry component, create a column in **FoodDetail**, and set the alignment to **alignItems(HorizontalAlign.Center)**. Change the name of the **MyComponent** component to **FoodImageDisplay**, which is a child component of the **FoodDetail** component. + A column is a container component whose child components are vertically arranged. It is a linear layout in essence. Therefore, only the alignment in the cross axis direction can be set. @@ -239,10 +240,11 @@ You can use the Flex layout to build a food composition table. In this way you d ``` 2. Create a Flex component to display two food composition categories in the tomato: Calories and Nutrition. - Calories contains information about calories. Nutrition contains information about protein, fat, carbohydrates, and vitamin C. - - Create the Calories class. Create a Flex component and set its height to 280, and the top, right, and left margins to 30. The Flex component contains three Text child components, which represent the category name (Calories), content name (Calories), and contain value (17 kcal), respectively. By default, child components in the Flex component are arranged horizontally. - + +Calories contains information about calories. Nutrition contains information about protein, fat, carbohydrates, and vitamin C. + +Create the Calories class. Create a Flex component and set its height to 280, and the top, right, and left margins to 30. The Flex component contains three Text child components, which represent the category name (Calories), content name (Calories), and contain value (17 kcal), respectively. By default, child components in the Flex component are arranged horizontally. + In the following example, code of FoodImageDisplay is omitted, and only code of ContentTable is provided. @@ -279,7 +281,7 @@ You can use the Flex layout to build a food composition table. In this way you d ![en-us_image_0000001267767869](figures/en-us_image_0000001267767869.png) -3. Adjust the layout and set the proportion (layoutWeight) of each part. Set the proportion of the category name to 1, and the total proportion of content name and content value to **2**. The content name and content value are in a same Flex, and the content name occupies all remaining space flexGrow(1). +3. Adjust the layout and set the proportion (layoutWeight) of each part. Set the proportion of the category name to **1**, and the total proportion of content name and content value to **2**. The content name and content value are in a same Flex, and the content name occupies all remaining space flexGrow(1). ``` @Component @@ -336,6 +338,7 @@ You can use the Flex layout to build a food composition table. In this way you d ![en-us_image_0000001267607901](figures/en-us_image_0000001267607901.png) 4. Create the **Nutrient** class in a similar process. Nutrition consists of four parts: Protein, Fat, Carbohydrates, and VitaminC. The names of the last three parts are omitted in the table and represented by spaces. + Set **FlexDirection.Column**, **FlexAlign.SpaceBetween**, and **ItemAlign.Start**. @@ -467,7 +470,7 @@ You can use the Flex layout to build a food composition table. In this way you d } ``` - When the IngredientItem API is called in the build method of ContentTable, this needs to be used to invoke the method in the scope of the component to distinguish the global method call. +When the ` IngredientItem` API is called in the build method of ContentTable, ` this ` needs to be used to invoke the method in the scope of the component to distinguish the global method call. ``` @@ -488,7 +491,7 @@ You can use the Flex layout to build a food composition table. In this way you d } ``` - The overall code of the ContentTable component is as follows: +The overall code of the ContentTable component is as follows: ``` @@ -537,6 +540,6 @@ You can use the Flex layout to build a food composition table. In this way you d } ``` - ![en-us_image_0000001222807792](figures/en-us_image_0000001222807792.png) +![en-us_image_0000001222807792](figures/en-us_image_0000001222807792.png) You've learned how to build a simple food details page. Read on to learn how to define the page layout and connection. diff --git a/en/application-dev/ui/ui-ts-layout-grid-container.md b/en/application-dev/ui/ui-ts-layout-grid-container.md index da57f1c5846db8db5355259df7906acbbab83401..62c6762258110f519c9866165ea3007b9936fd41 100644 --- a/en/application-dev/ui/ui-ts-layout-grid-container.md +++ b/en/application-dev/ui/ui-ts-layout-grid-container.md @@ -12,17 +12,17 @@ To implement grid layout, the declarative paradigm provides the [GridContainer]( ## Grid System -The grid system works in terms of columns, margins, and gutters. +The grid system works in terms of gutter, margin, and column. ![en-us_image_0000001217236574](figures/en-us_image_0000001217236574.png) -1. Gutters: +1. Gutter: Spacing between elements. You can define different clutter values for different device sizes as part of the overall grid layout specifications. For better results, make sure the gutter is not greater than the margin. -2. Margins: +2. Margin: Spacing around an item in the grid container. You can define different margin values for different device sizes as part of the overall grid layout specifications. -3. Columns: +3. Column: Main tool for positioning items in the grid layout. The grid container is divided into various numbers of columns based on the device size. The width per column is calculated based on the total number of columns while respecting the margin and clutter specifications. diff --git a/en/application-dev/ui/ui-ts-layout-mediaquery.md b/en/application-dev/ui/ui-ts-layout-mediaquery.md index 7fa8ff03fb2a023509e4ccc7e02685f28b5d046b..e448fb8fce7b3b90edb0bab5b607b326616ba779 100644 --- a/en/application-dev/ui/ui-ts-layout-mediaquery.md +++ b/en/application-dev/ui/ui-ts-layout-mediaquery.md @@ -15,11 +15,11 @@ Invoke the **mediaquery** API to set the media query condition and the callback, First, import the mediaquery module, as shown below: ``` - import mediaquery from '@ohos.mediaquery' +import mediaquery from '@ohos.mediaquery' ``` Then, use the **matchMediaSync** API to set the media query condition and save the returned listener, as shown below: ``` - listener = mediaquery.matchMediaSync('(orientation: landscape)') +listener = mediaquery.matchMediaSync('(orientation: landscape)') ``` Finally, register the callback using the saved listener, and change the page layout or implement service logic in the callback. When the media query condition is matched, the callback is triggered. The sample code is as follows: ``` @@ -39,13 +39,13 @@ listener.on('change', onPortrait) ``` Examples are as follows: -screen and (round-screen: true) // The query is valid when the device screen is round. + ` screen and (round-screen: true) ` // The query is valid when the device screen is round. -(max-height: 800) // The query is valid when the height does not exceed 800. + ` (max-height: 800) ` // The query is valid when the height does not exceed 800. -(height <= 800) // The query is valid when the height does not exceed 800. + ` (height <= 800) ` // The query is valid when the height does not exceed 800. -screen and (device-type: tv) or (resolution < 2) // The query is valid only when all media features are true. + ` screen and (device-type: tv) or (resolution < 2) ` // The query is valid only when all media features are true. ### media-type diff --git a/en/application-dev/website.md b/en/application-dev/website.md index f861c1efd34f0b1e94c6ac5df6e8edd4330b0afc..0395b61b66797ddc7409bde4239fcb0d650a9fbb 100644 --- a/en/application-dev/website.md +++ b/en/application-dev/website.md @@ -22,8 +22,7 @@ - [Page Ability Development](ability/fa-pageability.md) - [Service Ability Development](ability/fa-serviceability.md) - [Data Ability Development](ability/fa-dataability.md) - - [FA Widget Development](ability/fa-formability.md) - + - [FA Widget Development](ability/fa-formability.md) - Stage Model - [Stage Model Overview](ability/stage-brief.md) - [Ability Development](ability/stage-ability.md) @@ -276,7 +275,9 @@ - Vibrator - [Vibrator Overview](device/vibrator-overview.md) - [Vibrator Development](device/vibrator-guidelines.md) - - + - Update + - [Sample Server Overview](device/sample-server-overview.md) + - [Sample Server Development](device/sample-server-guidelines.md) - Device Usage Statistics - [Device Usage Statistics Overview](device-usage-statistics/device-usage-statistics-overview.md) - [Device Usage Statistics Development](device-usage-statistics/device-usage-statistics-dev-guide.md) @@ -294,10 +295,10 @@ - [Internationalization Overview](internationalization/international-overview.md) - [Internationalization Development (intl)](internationalization/intl-guidelines.md) - [Internationalization Development (i18n)](internationalization/i18n-guidelines.md) - - - - [Using Native APIs in Application Projects](napi/napi-guidelines.md) + - [OpenHarmony IDL Specifications and User Guide](IDL/idl-guidelines.md) + - Native APIs + - [Using Native APIs in Application Projects](napi/napi-guidelines.md) - Tools - - [DevEco Studio (OpenHarmony) User Guide](quick-start/deveco-studio-user-guide-for-openharmony.md) - Hands-On Tutorials - [Samples](https://gitee.com/openharmony/app_samples/blob/master/README.md) @@ -556,7 +557,6 @@ - [Built-in Enums](reference/arkui-ts/ts-appendix-enums.md) - APIs - Ability Framework - - [@ohos.ability.dataUriUtils](reference/apis/js-apis-DataUriUtils.md) - [@ohos.ability.errorCode ](reference/apis/js-apis-ability-errorCode.md) - [@ohos.ability.wantConstant](reference/apis/js-apis-ability-wantConstant.md) @@ -598,35 +598,29 @@ - [PermissionRequestResult](reference/apis/js-apis-permissionrequestresult.md) - [ProcessRunningInfo](reference/apis/js-apis-processrunninginfo.md) - [ServiceExtensionContext](reference/apis/js-apis-service-extension-context.md) - - [shellCmdResult](reference/apis/js-apis-application-shellCmdResult.md) - Common Event and Notification - - [@ohos.commonEvent](reference/apis/js-apis-commonEvent.md) - [@ohos.events.emitter](reference/apis/js-apis-emitter.md) - [@ohos.notification](reference/apis/js-apis-notification.md) - [@ohos.reminderAgent](reference/apis/js-apis-reminderAgent.md) - [EventHub](reference/apis/js-apis-eventhub.md) - Bundle Management - - [@ohos.bundle](reference/apis/js-apis-Bundle.md) - [@ohos.bundleState ](reference/apis/js-apis-deviceUsageStatistics.md) - [@ohos.zlib](reference/apis/js-apis-zlib.md) - UI Page - - [@ohos.animator](reference/apis/js-apis-animator.md) - [@ohos.mediaquery](reference/apis/js-apis-mediaquery.md) - [@ohos.prompt](reference/apis/js-apis-prompt.md) - [@ohos.router](reference/apis/js-apis-router.md) - Graphics - - [@ohos.display ](reference/apis/js-apis-display.md) - [@ohos.screenshot](reference/apis/js-apis-screenshot.md) - [@ohos.window](reference/apis/js-apis-window.md) - [webgl](reference/apis/js-apis-webgl.md) - [webgl2](reference/apis/js-apis-webgl2.md) - Media - - [@ohos.multimedia.audio](reference/apis/js-apis-audio.md) - [@ohos.multimedia.camera](reference/apis/js-apis-camera.md) - [@ohos.multimedia.image](reference/apis/js-apis-image.md) @@ -637,32 +631,26 @@ - [@ohos.intl](reference/apis/js-apis-intl.md) - [@ohos.resourceManager](reference/apis/js-apis-resource-manager.md) - Resource Scheduling - - [@ohos.backgroundTaskManager](reference/apis/js-apis-backgroundTaskManager.md) - [@ohos.workScheduler ](reference/apis/js-apis-workScheduler.md) - [@ohos.WorkSchedulerExtensionAbility](reference/apis/js-apis-WorkSchedulerExtensionAbility.md) - Custom Management - - [@ohos.configPolicy](reference/apis/js-apis-config-policy.md) - [@ohos.enterpriseDeviceManager](reference/apis/js-apis-enterprise-device-manager.md) - Security - - [@ohos.abilityAccessCtrl](reference/apis/js-apis-abilityAccessCtrl.md) - [@ohos.security.huks ](reference/apis/js-apis-huks.md) - [@ohos.userIAM.userAuth ](reference/apis/js-apis-useriam-userauth.md) - [@system.cipher](reference/apis/js-apis-system-cipher.md) - Data Management - - [@ohos.data.dataAbility ](reference/apis/js-apis-data-ability.md) - [@ohos.data.distributedData](reference/apis/js-apis-distributed-data.md) - [@ohos.data.distributedDataObject](reference/apis/js-apis-data-distributedobject.md) - [@ohos.data.preferences](reference/apis/js-apis-data-preferences.md) - [@ohos.data.rdb](reference/apis/js-apis-data-rdb.md) - - [@ohos.settings](reference/apis/js-apis-settings.md) - - - [resultSet](reference/apis/js-apis-data-resultset.md) + - [@ohos.settings](reference/apis/js-apis-settings.md) + - [resultSet](reference/apis/js-apis-data-resultset.md) - File Management - - [@ohos.document](reference/apis/js-apis-document.md) - [@ohos.environment](reference/apis/js-apis-environment.md) - [@ohos.fileio](reference/apis/js-apis-fileio.md) @@ -670,8 +658,7 @@ - [@ohos.statfs](reference/apis/js-apis-statfs.md) - [@ohos.storageStatistics](reference/apis/js-apis-storage-statistics.md) - [@ohos.volumeManager](reference/apis/js-apis-volumemanager.md) - - Telephony Service - + - Telephony - [@ohos.contact](reference/apis/js-apis-contact.md) - [@ohos.telephony.call](reference/apis/js-apis-call.md) - [@ohos.telephony.observer](reference/apis/js-apis-observer.md) @@ -686,14 +673,12 @@ - [@ohos.net.socket](reference/apis/js-apis-socket.md) - [@ohos.net.webSocket](reference/apis/js-apis-webSocket.md) - Connectivity - - [@ohos.bluetooth](reference/apis/js-apis-bluetooth.md) - [@ohos.connectedTag](reference/apis/js-apis-connectedTag.md) - [@ohos.rpc](reference/apis/js-apis-rpc.md) - [@ohos.wifi](reference/apis/js-apis-wifi.md) - [@ohos.wifiext](reference/apis/js-apis-wifiext.md) - Basic Features - - [@ohos.accessibility](reference/apis/js-apis-accessibility.md) - [@ohos.faultLogger](reference/apis/js-apis-faultLogger.md) - [@ohos.hiAppEvent](reference/apis/js-apis-hiappevent.md) @@ -710,7 +695,6 @@ - [@ohos.wallpaper](reference/apis/js-apis-wallpaper.md) - [Timer](reference/apis/js-apis-timer.md) - Device Management - - [@ohos.batteryInfo ](reference/apis/js-apis-battery-info.md) - [@ohos.brightness](reference/apis/js-apis-brightness.md) - [@ohos.deviceInfo](reference/apis/js-apis-device-info.md) @@ -729,12 +713,10 @@ - [@ohos.usb](reference/apis/js-apis-usb.md) - [@ohos.vibrator](reference/apis/js-apis-vibrator.md) - Account Management - - [@ohos.account.appAccount](reference/apis/js-apis-appAccount.md) - [@ohos.account.distributedAccount](reference/apis/js-apis-distributed-account.md) - [@ohos.account.osAccount](reference/apis/js-apis-osAccount.md) - Language Base Class Library - - [@ohos.convertxml](reference/apis/js-apis-convertxml.md) - [@ohos.process](reference/apis/js-apis-process.md) - [@ohos.uri](reference/apis/js-apis-uri.md) @@ -760,7 +742,6 @@ - [@ohos.application.testRunner](reference/apis/js-apis-testRunner.md) - [@ohos.uitest](reference/apis/js-apis-uitest.md) - APIs No Longer Maintained - - [@ohos.bytrace](reference/apis/js-apis-bytrace.md) - [@ohos.data.storage](reference/apis/js-apis-data-storage.md) - [@system.app](reference/apis/js-apis-system-app.md) diff --git a/en/contribute/code-contribution.md b/en/contribute/code-contribution.md index 745343f109f954238b11df0c1eafa20594550176..4c340a50ad319bdb122658d6f6bfea7c034de72d 100644 --- a/en/contribute/code-contribution.md +++ b/en/contribute/code-contribution.md @@ -29,7 +29,6 @@ For details, see [Contribution Process](contribution-process.md). ## Security Issue Disclosure - [Security Issue Handling and Release Processes](https://gitee.com/openharmony/security/blob/master/en/security-process/README.md) - - [OpenHarmony Security Vulnerability Notice](https://gitee.com/openharmony/security/blob/master/en/security-process/security-disclosure.md) diff --git a/en/device-dev/Readme-EN.md b/en/device-dev/Readme-EN.md index 2e69d001546138f62485054ac99131acaa9a4151..da79e395fe463e47d3606de98f799e3e306d3b0e 100644 --- a/en/device-dev/Readme-EN.md +++ b/en/device-dev/Readme-EN.md @@ -43,10 +43,10 @@ - [Mini- and Small-System Devices](guide/device-lite.md) - [Standard-System Devices](guide/device-standard.md) - Debugging - - [Test](subsystems/subsys-testguide-test.md) + - [Test Case Development](subsystems/subsys-testguide-test.md) - [R&D Tools](subsystems/subsys-toolchain.md) - XTS Certification - - [XTS](subsystems/subsys-xts-guide.md) + - [XTS Test Case Development](subsystems/subsys-xts-guide.md) - Tools - [Docker Environment](get-code/gettools-acquire.md) - [IDE](get-code/gettools-ide.md) diff --git a/en/device-dev/driver/driver-peripherals-pinauth-des.md b/en/device-dev/driver/driver-peripherals-pinauth-des.md index 85ea44728678ac23169513ebc96018457d06754f..22a619ae00057269f1adf025c14c86bc1544095f 100644 --- a/en/device-dev/driver/driver-peripherals-pinauth-des.md +++ b/en/device-dev/driver/driver-peripherals-pinauth-des.md @@ -4,16 +4,16 @@ ### Function -Personal Identification Number (PIN) authentication provides user authentication capabilities and applies to identity authentication scenarios, such as device unlocking, payment, and app logins. After a user registers a PIN, the PIN authentication (pin_auth) module unlocks the device only when a correct PIN is entered. The figure below shows the architecture of PIN authentication. +Personal Identification Number (PIN) authentication provides user authentication capabilities in identity authentication scenarios, such as device unlocking, payment, and app logins. After a user registers a PIN, the PIN authentication (pin_auth) module unlocks the device only when a correct PIN is entered. The figure below shows the architecture of PIN authentication. -The pin_auth driver is developed based on the Hardware Driver Foundation (HDF). The pin_auth driver model shields hardware differences and provides stable PIN authentication capabilities for the user IAM framework(UserIAM) and PIN authentication system ability (SA). The PIN authentication capabilities include obtaining the PIN authentication executor list, executor information, anti-brute force information of the specified template, comparing the template list of the executor and that of UserIAM, enrolling or deleting PINs, and performing PIN authentication. +The pin_auth driver is developed based on the Hardware Driver Foundation (HDF). The pin_auth driver model shields hardware differences and provides stable PIN authentication capabilities for the user IAM framework(UserIAM) and PIN authentication system ability (SA). The PIN authentication capabilities include obtaining the PIN authentication executor list, executor information, and anti-brute force information of the specified template, comparing the template list of the executor and that of UserIAM, enrolling or deleting PINs, and performing PIN authentication. **Figure 1** PIN authentication architecture ![image](figures/pin_auth_architecture.png "PIN authentication architecture") ### Basic Concepts -The identity authentication consists of UserIAM and basic authentication services (including PIN authentication and facial recognition). It supports basic functions such as setting and deleting user credentials, deletion, and performing authentication. +The identity authentication consists of UserIAM and basic authentication services (including PIN authentication and facial recognition). It supports basic functions such as setting and deleting user credentials, and performing authentication. - Executor @@ -37,7 +37,7 @@ The identity authentication consists of UserIAM and basic authentication service - UserIAM public key & executor public key - To ensure user data security and authentication result accuracy, measures must be taken to protect the integrity of the key information exchanged between UserIAM and basic authentication services. Public keys need to be exchanged when the executor provided by a basic authentication service interworks with UserIAM. + To ensure user data security and authentication result accuracy, measures must be taken to protect the integrity of the key information exchanged between UserIAM and basic authentication services. Public keys must be exchanged when the executor provided by a basic authentication service interworks with UserIAM. - The executor uses the UserIAM public key to verify the scheduling instruction. @@ -50,7 +50,7 @@ The identity authentication consists of UserIAM and basic authentication service - Data verification by the executor - UserIAM manages the mappings between user identities and credential IDs in a unified manner. When connecting to UserIAM, the executor obtains the template ID list from UserIAM, compares its template ID list with the template ID list obtained, and updates its template ID list accordingly. + UserIAM manages the mappings between user identities and credential IDs in a unified manner. When connecting to UserIAM, the executor obtains the template ID list from UserIAM, and updates its template ID list based on the obtained template ID list. ### Working Principles @@ -65,7 +65,7 @@ PIN authentication must be implemented in a TEE, and the confidential informatio ## Development Guidelines ### When to Use -The pin_auth driver provides basic capabilities of PIN authentication for the UserIAM and pin_auth service to ensure successful PIN authentication. +The pin_auth driver provides basic PIN authentication capabilities for the UserIAM and pin_auth service to ensure successful PIN authentication. ### Available APIs @@ -499,7 +499,7 @@ The development procedure is as follows: return HDF_SUCCESS; } - // Cancel the operation of the specified scheduleId. + // Cancel the operation based on the specified scheduleId. int32_t ExecutorImpl::Cancel(uint64_t scheduleId) { IAM_LOGI("start"); diff --git a/en/device-dev/driver/driver-peripherals-touch-des.md b/en/device-dev/driver/driver-peripherals-touch-des.md index 4f2a3428a67794eff0fb557d6386c7be111e5f11..84b4929ef27b5524c88c217722abafd44282c75d 100644 --- a/en/device-dev/driver/driver-peripherals-touch-des.md +++ b/en/device-dev/driver/driver-peripherals-touch-des.md @@ -88,7 +88,7 @@ Perform the following steps: 1. Add the touchscreen driver-related descriptions. - Currently, the input driver is developed based on the HDF and is loaded and started by the HDF. Register the driver information, such as whether to load the driver and the loading priority in the configuration file. Then, the HDF starts the registered driver modules one by one. For details about the driver configuration, see [How to Develop](driver-hdf-development.md#how-to-develop). + Currently, the input driver is developed based on the HDF and is loaded and started by the HDF. Register the driver information, such as whether to load the driver and the loading priority in the configuration file. Then, the HDF starts the registered driver modules one by one. For details about the driver configuration, see [How to Develop](driver-hdf-development.md). 2. Complete the board-level configuration and private data configuration of the touchscreen. @@ -105,7 +105,7 @@ This example describes how to develop the touchscreen driver. ### Adding the Touchscreen Driver-related Description -The information about modules of the input driver model is shown as follows and enables the HDF to load the modules in sequence. For details, see [Driver Development](driver-hdf-development.md). +The information about modules of the input driver model is shown as follows and enables the HDF to load the modules in sequence. For details, see [Driver Development](driver-hdf-development.md). ``` input :: host { diff --git a/en/device-dev/driver/driver-platform-adc-des.md b/en/device-dev/driver/driver-platform-adc-des.md index 96f5fd9458881a7ec11702069977497ff274407a..14cd3630fbf47e4b61a436dc684792664f6410fb 100644 --- a/en/device-dev/driver/driver-platform-adc-des.md +++ b/en/device-dev/driver/driver-platform-adc-des.md @@ -5,10 +5,11 @@ An analog-to-digital converter (ADC) is a device that converts analog signals into digital signals. The ADC APIs provide a set of common functions for ADC data transfer, including: -- Opening or closing an ADC device +- Opening or closing an ADC device + - Obtaining the analog-to-digital (AD) conversion result - **Figure 1** ADC physical connection + **Figure 1** ADC physical connection ![](figures/ADC_physical_connection.png "ADC_physical_connection") @@ -51,11 +52,11 @@ The ADC APIs provide a set of common functions for ADC data transfer, including: ### How to Use -[Figure 2](#fig2) shows how an ADC device works. +The figure below illustrates how to use the APIs. + + **Figure 2** Using ADC driver APIs - **Figure 2** How ADC works - -![](figures/ADC_flowchart.png "ADC_flowchart") +![](figures/using-ADC-process.png "using-ADC-process.png") ### Opening an ADC Device diff --git a/en/device-dev/driver/driver-platform-dac-des.md b/en/device-dev/driver/driver-platform-dac-des.md index 8d55f1da22283d10b5d6a9e9a5f9707c0faa5968..45cd858317a5affefb3bb285322f73c92b0b380c 100644 --- a/en/device-dev/driver/driver-platform-dac-des.md +++ b/en/device-dev/driver/driver-platform-dac-des.md @@ -69,15 +69,15 @@ The table below describes the APIs of the DAC module. For more details, see API | :------------------------------------------------------------| :------------ | | DevHandle DacOpen(uint32_t number) | Opens a DAC device. | | void DacClose(DevHandle handle) | Closes a DAC device. | -| int32_t DacWrite(DevHandle handle, uint32_t channel, uint32_t val) | Sets the target DA value. | +| int32_t DacWrite(DevHandle handle, uint32_t channel, uint32_t val) | Sets a target DA value. | ### How to Develop -The figure below illustrates the process of using a DAC device. +The figure below illustrates how to use the APIs. -**Figure 2** Process of using a DAC device - -![](figures/process-of-using-DAC.png "Process of using a DAC") +**Figure 2** Using DAC driver APIs + +![](figures/using-DAC-process.png "using-DAC-process.png") #### Opening a DAC Device @@ -111,7 +111,7 @@ if (dacHandle == NULL) { } ``` -#### Setting the Target DA Value +#### Setting a Target DA Value ``` int32_t DacWrite(DevHandle handle, uint32_t channel, uint32_t val); diff --git a/en/device-dev/driver/driver-platform-gpio-des.md b/en/device-dev/driver/driver-platform-gpio-des.md index 78928d8de19810dd39585044c032badb00e4b34f..04a850623ec868bcfb94ec22c345959c783e4303 100644 --- a/en/device-dev/driver/driver-platform-gpio-des.md +++ b/en/device-dev/driver/driver-platform-gpio-des.md @@ -7,11 +7,11 @@ Generally, a general-purpose input/output \(GPIO\) controller manages all GPIO p The GPIO APIs define a set of standard functions for performing operations on GPIO pins, including: -- Setting the pin direction, which can be input or output \(High impedance is not supported currently.\) +- Setting the pin direction, which can be input or output \(high impedance is not supported currently\) - Reading and writing level values, which can be low or high - Setting an interrupt service routine \(ISR\) function and interrupt trigger mode for a pin -- Enabling or disabling a pin interrupt +- Enabling or disabling interrupts for a pin ## Available APIs @@ -64,17 +64,18 @@ The GPIO APIs define a set of standard functions for performing operations on GP

GpioEnableIrq

-

Enables a GPIO interrupt.

+

Enables GPIO interrupts for a pin.

GpioDisableIrq

-

Disables a GPIO interrupt.

+

Disables GPIO interrupts for a pin.

+ >![](../public_sys-resources/icon-note.gif) **NOTE**
>All functions provided in this document can be called only in kernel mode. @@ -82,22 +83,27 @@ The GPIO APIs define a set of standard functions for performing operations on GP ### How to Use -The GPIO APIs use the GPIO pin number to specify a pin. [Figure 1](#fig16151101653713) shows the general process of using a GPIO. +The GPIO APIs use the GPIO pin number to specify a pin. The figure below illustrates how to use the APIs. + +**Figure 1** Using GPIO driver APIs + +![](figures/using-gpio-process.png "using-gpio-process.png") -**Figure 1** Process of using a GPIO -![](figures/process-of-using-a-gpio.png "process-of-using-a-gpio") +### Determining the GPIO Pin Number -### Determining a GPIO Pin Number +The method for converting GPIO pin numbers varies depending on the GPIO controller model, parameters, and controller driver of different system on chips \(SoCs\). -The method for converting GPIO pin numbers varies according to the GPIO controller model, parameters, and controller driver of different system on chips \(SoCs\). +- Hi3516DV300 -- Hi3516DV300 + A controller manages 12 groups of GPIO pins. Each group contains 8 GPIO pins. - A controller manages 12 groups of GPIO pins. Each group contains 8 GPIO pins. + GPIO pin number = GPIO group index x Number of GPIO pins in each group + Offset in the group - GPIO pin number = GPIO group index \(0–11\) x Number of GPIO pins in each group \(8\) + Offset in the group + The group index ranges from 0 to 11. - Example: GPIO number of GPIO10\_3 = 10 x 8 + 3 = 83 + Example: + + GPIO pin number of GPIO10\_3 = 10 x 8 + 3 = 83 - Hi3518EV300 @@ -105,14 +111,18 @@ The method for converting GPIO pin numbers varies according to the GPIO controll GPIO pin number = GPIO group index \(0–9\) x Number of GPIO pins in each group \(10\) + Offset in the group - Example: GPIO pin number of GPIO7\_3 = 7 x 10 + 3 = 73 + The group index ranges from 0 to 9. + + Example: + + GPIO pin number of GPIO7\_3 = 7 x 10 + 3 = 73 ### Using APIs to Operate GPIO Pins - Set the direction for a GPIO pin. - Before performing read/write operations on a GPIO pin, call the following function to set the direction: + Before performing read/write operations on a GPIO pin, call **GpioSetDir**() to set the direction. int32\_t GpioSetDir\(uint16\_t gpio, uint16\_t dir\); @@ -141,12 +151,12 @@ The method for converting GPIO pin numbers varies according to the GPIO controll

0

-

Succeeded in setting the direction for a GPIO pin.

+

The operation is successful.

Negative value

-

Failed to set the direction for a GPIO pin.

+

The operation failed.

@@ -155,7 +165,7 @@ The method for converting GPIO pin numbers varies according to the GPIO controll - Read or write the level value for a GPIO pin. - To read the level value of a GPIO pin, call the following function: + Call **GpioRead**() to read the level value of a GPIO pin. int32\_t GpioRead\(uint16\_t gpio, uint16\_t \*val\); @@ -184,23 +194,24 @@ The method for converting GPIO pin numbers varies according to the GPIO controll

0

-

Succeeded in reading the level value.

+

The operation is successful.

Negative value

-

Failed to read the level value.

+

The operation failed.

- - To write the level value for a GPIO pin, call the following function: - + + + Call **GpioWrite()** to write the level value for a GPIO pin. + int32\_t GpioWrite\(uint16\_t gpio, uint16\_t val\); - + **Table 4** Description of GpioWrite - + @@ -224,19 +235,19 @@ The method for converting GPIO pin numbers varies according to the GPIO controll - -

Parameter

0

Succeeded in writing the level value.

+

The operation is successful.

Negative value

Failed to write the level value.

+

The operation failed.

- + Example: - + ``` int32_t ret; uint16_t val; @@ -265,7 +276,7 @@ The method for converting GPIO pin numbers varies according to the GPIO controll - Set the ISR function for a GPIO pin. - To set the ISR function for a GPIO pin, call the following function: + Call **GpioSetIrq()** to set the ISR function for a GPIO pin. int32\_t GpioSetIrq\(uint16\_t gpio, uint16\_t mode, GpioIrqFunc func, void \*arg\); @@ -304,21 +315,21 @@ The method for converting GPIO pin numbers varies according to the GPIO controll

0

-

Succeeded in setting the ISR function for a GPIO pin.

+

The operation is successful.

Negative value

-

Failed to set the ISR function for a GPIO pin.

+

The operation failed.

- >![](../public_sys-resources/icon-caution.gif) **CAUTION:** + >![](../public_sys-resources/icon-caution.gif) **CAUTION**
>Only one ISR function can be set for a GPIO pin at a time. If **GpioSetIrq** is called repeatedly, the previous IRS function will be replaced. - If the ISR function is no longer required, call the following function to cancel the setting: + If the ISR function is no longer required, call **GpioUnSetIrq()** to cancel the setting. int32\_t GpioUnSetIrq\(uint16\_t gpio\); @@ -342,18 +353,18 @@ The method for converting GPIO pin numbers varies according to the GPIO controll

0

-

Succeeded in canceling the ISR function.

+

The operation is successful.

Negative value

-

Failed to cancel the ISR function.

+

The operation failed.

- After the ISR function is set, call the following function to enable a GPIO interrupt: + After the ISR function is set, call **GpioEnableIrq()** to enable interrupts. int32\_t GpioEnableIrq\(uint16\_t gpio\); @@ -377,21 +388,21 @@ The method for converting GPIO pin numbers varies according to the GPIO controll

0

-

Succeeded in enabling a GPIO interrupt.

+

The operation is successful.

Negative value

-

Failed to enable a GPIO interrupt.

+

The operation failed.

- >![](../public_sys-resources/icon-caution.gif) **CAUTION:** + >![](../public_sys-resources/icon-caution.gif) **CAUTION**
>The configured ISR function can be responded only after the GPIO interrupt is enabled. - Use the following function to disable the GPIO interrupt: + Call **GpioDisableIrq()** to disable interrupts. int32\_t GpioDisableIrq\(uint16\_t gpio\); @@ -415,12 +426,12 @@ The method for converting GPIO pin numbers varies according to the GPIO controll

0

-

Succeeded in disabling a GPIO interrupt.

+

The operation is successful.

Negative value

-

Failed to disable a GPIO interrupt.

+

The operation failed.

@@ -470,11 +481,15 @@ The method for converting GPIO pin numbers varies according to the GPIO controll ## Usage Example -In this example, we test the interrupt trigger of a GPIO pin as follows: Set the ISR function for the pin, set the trigger mode to rising edge and failing edge, write high and low levels to the pin alternately to generate level fluctuation, and observe the execution of the ISR function. +The procedure is as follows: + +1. Select an idle GPIO pin. + + This example uses pin GPIO10\_3 on a Hi3516D V300 development board as an example. The pin number is 83. You can select an idle GPIO pin as required. -Select an idle GPIO pin. This example uses a Hi3516D V300 development board and GPIO pin GPIO10\_3, which is numbered GPIO83. +2. Set the ISR function for the pin, with the trigger mode of rising edge and failing edge. -You can select an idle GPIO pin based on the development board and schematic diagram. +3. Write high and low levels to the pin alternately, and observe the execution of the ISR function. ``` #include "gpio_if.h" diff --git a/en/device-dev/driver/driver-platform-i2c-des.md b/en/device-dev/driver/driver-platform-i2c-des.md index 16b1d22f7a2f02985671934100642647f828ad8f..be20c1bf72268eb594a56f86ae55f6b7e4ae8d90 100644 --- a/en/device-dev/driver/driver-platform-i2c-des.md +++ b/en/device-dev/driver/driver-platform-i2c-des.md @@ -2,19 +2,20 @@ ## Overview -- The Inter-Integrated Circuit \(I2C\) is a simple, bidirectional, and synchronous serial bus that uses merely two wires. -- In an I2C communication, one controller communicates with one or more devices through the serial data line \(SDA\) and serial clock line \(SCL\), as shown in [Figure 1](#fig1135561232714). +The Inter-Integrated Circuit \(I2C\) is a simple, bidirectional, and synchronous serial bus that uses merely two wires. -- I2C data transfer must begin with a **START** condition and end with a **STOP** condition. Data is transmitted byte-by-byte from the most significant bit to the least significant bit. -- Each I2C node is recognized by a unique address and can serve as either a controller or a device. When the controller needs to communicate with a device, it writes the device address to the bus through broadcast. A device matching this address sends a response to set up a data transfer channel. +In an I2C communication, one controller communicates with one or more devices through the serial data line \(SDA\) and serial clock line \(SCL\), as shown in [Figure 1](#fig1135561232714). -- The I2C APIs define a set of common functions for I2C data transfer, including: +I2C data transfer must begin with a **START** condition and end with a **STOP** condition. Data is transmitted byte-by-byte from the most significant bit to the least significant bit. - - I2C controller management: opening or closing an I2C controller - - I2C message transfer: custom transfer by using a message array +Each I2C node is recognized by a unique address and can serve as either a controller or a device. When the controller needs to communicate with a device, it writes the device address to the bus through broadcast. A device matching this address sends a response to set up a data transfer channel. - **Figure 1** Physical connection diagram for I2C - ![](figures/physical-connection-diagram-for-i2c.png "physical-connection-diagram-for-i2c") +The I2C APIs define a set of common functions for I2C data transfer, including: + +- I2C controller management: opening or closing an I2C controller +- I2C message transfer: custom transfer by using a message array + +**Figure 1** Physical connection diagram for I2C
![](figures/physical-connection-diagram-for-i2c.png "physical-connection-diagram-for-i2c") ## Available APIs @@ -52,21 +53,22 @@ ->![](../public_sys-resources/icon-note.gif) **NOTE:** +>![](../public_sys-resources/icon-note.gif) **NOTE**
>All functions provided in this document can be called only in kernel mode. ## Usage Guidelines ### How to Use -[Figure 2](#fig183017194234) illustrates the process of an I2C device. +The figure below illustrates how to use the APIs. -**Figure 2** Process of using an I2C device -![](figures/process-of-using-an-i2c-device.png "process-of-using-an-i2c-device") +**Figure 2** Using I2C driver APIs + +![](figures/using-i2c-process.png "process-of-using-an-i2c-device") ### Opening an I2C Controller -Call the following function to open an I2C controller: +Call the **I2cOpen()** function to open an I2C controller. DevHandle I2cOpen\(int16\_t number\); @@ -117,7 +119,7 @@ if (i2cHandle == NULL) { ### Performing I2C Communication -Use the following function for message transfer: +Call the **I2cTransfer()** function to transfer messages. int32\_t I2cTransfer\(DevHandle handle, struct I2cMsg \*msgs, int16\_t count\); @@ -186,15 +188,14 @@ if (ret != 2) { } ``` ->![](../public_sys-resources/icon-caution.gif) **CAUTION:** +>![](../public_sys-resources/icon-caution.gif) **CAUTION**
>- The device address in the **I2cMsg** structure does not contain the read/write flag bit. The read/write information is transferred by the read/write control bit in the member variable **flags**. ->- The **I2cTransfer** function does not limit the number of message structures, which is determined by the I2C controller. ->- The **I2cTransfer** function does not limit the data length of each message structure, which is determined by the I2C controller. +>- The **I2cTransfer** function does not limit the number of message structures and the data length of each message structure, which are determined by the I2C controller. >- The **I2cTransfer** function may cause the system to sleep and therefore cannot be called in the interrupt context. ### Closing an I2C Controller -Call the following function to close the I2C controller after the communication is complete: +Call the **I2cClose()** function to close the I2C controller after the communication is complete. void I2cClose\(DevHandle \*handle\); @@ -209,12 +210,13 @@ void I2cClose\(DevHandle \*handle\);

handle

-

Handle of an I2C controller.

+

Handle of the I2C controller to close.

+ ``` I2cClose(i2cHandle); /* Close the I2C controller. */ ``` @@ -233,7 +235,7 @@ This example shows a simple register read/write operation on TouchPad on a Hi351 In this example, first we reset Touch IC. \(The development board supplies power to Touch IC by default after being powered on, and this use case does not consider the power supply\). Then, we perform a read/write operation on an internal register to test whether the I2C channel is normal. ->![](../public_sys-resources/icon-note.gif) **NOTE:** +>![](../public_sys-resources/icon-note.gif) **NOTE**
>The example focuses on I2C device access and verifies the I2C channel. The read and write values of the device register are not concerned. The behavior caused by the read and write operations on the register is determined by the device itself. Example: diff --git a/en/device-dev/driver/driver-platform-mipicsi-des.md b/en/device-dev/driver/driver-platform-mipicsi-des.md index cd877612d26e3451d2ca57a4d3929c9f14fa6547..90a319f03db175e2019cc71d32130492077d63b9 100644 --- a/en/device-dev/driver/driver-platform-mipicsi-des.md +++ b/en/device-dev/driver/driver-platform-mipicsi-des.md @@ -59,12 +59,11 @@ The figure below shows a simplified CSI. The D-PHY transmits data by using one p ### How to Use -The figure below shows the process of using a MIPI CSI device. +The figure below illustrates how to use the APIs. -**Figure 2** MIPI CSI usage process +**Figure 2** Using MIPI CSI driver APIs - -![](figures/process-of-using-MIPI-CSI.png) +![](figures/using-MIPI-CSI-process.png) ### Opening the MIPI CSI Controller Operation Handle diff --git a/en/device-dev/driver/driver-platform-mipidsi-des.md b/en/device-dev/driver/driver-platform-mipidsi-des.md index 3845f8078cbba3d796b8a9061158eef306360aba..889a4ff840d65c67a4bc2ffbf47cc91667bed38c 100644 --- a/en/device-dev/driver/driver-platform-mipidsi-des.md +++ b/en/device-dev/driver/driver-platform-mipidsi-des.md @@ -1,6 +1,6 @@ -# MIPI DSI +# MIPI DSI -## Overview +## Overview The Display Serial Interface \(DSI\) is a specification stipulated by the Mobile Industry Processor Interface \(MIPI\) Alliance, aiming to reduce the cost of display controllers in a mobile device. It defines a serial bus and communication protocol among the host, the source of image data, and the target device. In this way, the DSI can send pixel data or commands to peripherals \(usually LCDs or similar display devices\) in serial mode, or reads information such as status and pixel from the peripherals. @@ -11,7 +11,7 @@ MIPI DSI is capable of working in both high speed \(HS\) mode and low power \(LP ![](figures/dsi-transmitting-and-receiving-interface.png "dsi-transmitting-and-receiving-interface") -## Available APIs +## Available APIs **Table 1** APIs for MIPI DSI @@ -75,17 +75,17 @@ MIPI DSI is capable of working in both high speed \(HS\) mode and low power \(LP ->![](../public_sys-resources/icon-note.gif) **NOTE**
->All functions described in this document can be called only in kernel space. +>![](../public_sys-resources/icon-note.gif) **NOTE**
All functions described in this document can be called only in kernel space. -## Usage Guidelines +## Usage Guidelines -### How to Use +### How to Use -[Figure 2](#fig129103491241) shows the process of using a MIPI DSI device. +The figure below illustrates how to use the APIs. -**Figure 2** Process of using a MIPI DSI device -![](figures/process-of-using-a-mipi-dsi-device.png) +**Figure 2** Using MIPI DSI driver APIs + + ![](figures/using-mipi-dsi-process.png) ### Obtaining a MIPI DSI Device Handle diff --git a/en/device-dev/driver/driver-platform-pin-des.md b/en/device-dev/driver/driver-platform-pin-des.md index fe73cbd7cb9933bad74359070642bb26c5643c46..607807085a5334b9b975e840c44406ad3992ad06 100644 --- a/en/device-dev/driver/driver-platform-pin-des.md +++ b/en/device-dev/driver/driver-platform-pin-des.md @@ -68,10 +68,11 @@ The table below describes the APIs of the pin module. For more details, see API ### How to Develop -The figure below shows the process. +The figure below illustrates how to use the APIs. - **Figure 2** Process of using the pin module -![](figures/process-of-using-pin.png "Process of using the pin module") + **Figure 2** Using the pin driver APIs + +![](figures/using-pin-process.png "Process of using the pin module") #### Obtaining the Pin Description Handle @@ -122,7 +123,7 @@ int32_t PinSetPull(DevHandle handle, enum PinPullType pullType); | pullType | Pull type to set. | | **Return Value**| **Description** | | 0 | The operation is successful.| -| Negative value | The operation fails.| +| Negative value | The operation failed.| Example: Set the pull type to pull-up. @@ -156,7 +157,7 @@ int32_t PinGetPull(DevHandle handle, enum PinPullType *pullType); | pullType | Pointer to the pull type obtained.| | **Return Value**| **Description** | | 0 | The operation is successful. | -| Negative value | The operation fails. | +| Negative value | The operation failed. | Example: Obtain the pull type of a pin. @@ -189,7 +190,7 @@ int32_t PinSetStrength(DevHandle handle, uint32_t strength); | strength | Pull strength to set. | | **Return Value**| **Description** | | 0 | The operation is successful.| -| Negative value | The operation fails.| +| Negative value | The operation failed.| Example: Set the pull strength of the pin to 2. @@ -223,7 +224,7 @@ int32_t PinGetStrength(DevHandle handle, uint32_t *strength); | strength | Pointer to the pull strength obtained.| | **Return Value**| **Description** | | 0 | The operation is successful. | -| Negative value | The operation fails. | +| Negative value | The operation failed. | Example: Obtain the pull strength of a pin. @@ -258,7 +259,7 @@ int32_t PinSetFunc(DevHandle handle, const char *funcName); | funcName | Pointer to the pin function to set. | | **Return Value**| **Description** | | 0 | The operation is successful.| -| Negative value | The operation fails.| +| Negative value | The operation failed.| Example: Set the pin function to LSADC_CH1 (ADC channel 1). @@ -291,7 +292,7 @@ int32_t PinGetFunc(DevHandle handle, const char **funcName); | funcName | Pointer to the function name obtained.| | **Return Value**| **Description** | | 0 | The operation is successful. | -| Negative value | The operation fails. | +| Negative value | The operation failed. | Example: Obtain the pin function. diff --git a/en/device-dev/driver/driver-platform-pwm-des.md b/en/device-dev/driver/driver-platform-pwm-des.md index c87a2deeb1ef03fbd2f1c309bc04cfbf539d69bc..6330ccc91b558b134b46f5d0f8cea867823466e7 100644 --- a/en/device-dev/driver/driver-platform-pwm-des.md +++ b/en/device-dev/driver/driver-platform-pwm-des.md @@ -48,11 +48,11 @@ Pulse width modulation (PWM) is a technology that digitally encodes analog signa ### How to Use -The figure below shows the general process of using the PWM. +The figure below illustrates how to use the APIs. - **Figure 1** Process of using the PWM module +**Figure 1** Using the PWM driver APIs -![](figures/process-of-using-PWM.png) +![](figures/using-PWM-process.png) ### Opening a PWM Device Handle @@ -71,7 +71,7 @@ DevHandle PwmOpen(uint32_t num); | num | PWM device number. | | **Return Value** | **Description** | | handle | Handle of the PWM device obtained.| -| NULL | The operation fails. | +| NULL | The operation failed. | Example: Open the device handle of PWM device 0. @@ -126,7 +126,7 @@ int32_t PwmEnable(DevHandle handle); | handle | PWM device handle. | | **Return Value** | **Description** | | 0 | The operation is successful. | -| Negative number | The operation fails. | +| Negative number | The operation failed. | ``` @@ -156,7 +156,7 @@ int32_t PwmDisable(DevHandle handle); | handle | PWM device handle. | | **Return Value** | **Description** | | 0 | The operation is successful. | -| Negative number | The operation fails. | +| Negative number | The operation failed. | ``` @@ -187,7 +187,7 @@ int32_t PwmSetPeriod(DevHandle handle, uint32_t period); | period | PWM period to set, in ns.| | **Return Value**| **Description** | | 0 | The operation is successful. | -| Negative number | The operation fails. | +| Negative number | The operation failed. | ``` @@ -218,7 +218,7 @@ int32_t PwmSetDuty(DevHandle handle, uint32_t duty); | duty | Time that the signal is in the ON state, in ns.| | **Return Value**| **Description** | | 0 | The operation is successful. | -| Negative number | The operation fails. | +| Negative number | The operation failed. | ``` @@ -249,7 +249,7 @@ int32_t PwmSetPolarity(DevHandle handle, uint8_t polarity); | polarity | Polarity to set, which can be **PWM\_NORMAL\_POLARITY** or **PWM\_INVERTED\_POLARITY**.| | **Return Value**| **Description** | | 0 | The operation is successful. | -| Negative number | The operation fails. | +| Negative number | The operation failed. | ``` @@ -280,7 +280,7 @@ int32_t PwmSetConfig(DevHandle handle, struct PwmConfig *config); | \*config | Pointer to PWM parameters. | | **Return Value**| **Description** | | 0 | The operation is successful. | -| Negative number | The operation fails. | +| Negative number | The operation failed. | ``` @@ -317,7 +317,7 @@ int32_t PwmGetConfig(DevHandle handle, struct PwmConfig *config); | \*config | Pointer to PWM parameters. | | **Return Value**| **Description** | | 0 | The operation is successful. | -| Negative number | The operation fails. | +| Negative number | The operation failed. | ``` diff --git a/en/device-dev/driver/driver-platform-regulator-des.md b/en/device-dev/driver/driver-platform-regulator-des.md index 0131dae05046bd67c73b0cd625e9cf203f79b6d5..eacf890176325fdfbb8aa9c49ce7c612ed3fdaaa 100644 --- a/en/device-dev/driver/driver-platform-regulator-des.md +++ b/en/device-dev/driver/driver-platform-regulator-des.md @@ -42,7 +42,8 @@ The regulator module is divided into the following layers: - The core layer provides the capabilities of binding, initializing, and releasing devices. - The adaptation layer implements other functions. -![](../public_sys-resources/icon-note.gif)NOTE
The core layer can call the functions of the interface layer and uses the hook to call functions of the adaptation layer. In this way, the adaptation layer can indirectly call the functions of the interface layer, but the interface layer cannot call the functions of the adaptation layer. +> ![icon-note.gif](../public_sys-resources/icon-note.gif) **NOTE**
+> The core layer can call the functions of the interface layer and uses the hook to call functions of the adaptation layer. In this way, the adaptation layer can indirectly call the functions of the interface layer, but the interface layer cannot call the functions of the adaptation layer. **Figure 1** Unified service mode @@ -84,11 +85,11 @@ Regulators are used to: During the OS startup process, the driver management module loads the regulator driver based on the configuration file. Then, the regulator driver detects the regulator devices and initializes the driver. -The figure below illustrates the process of using a regulator. +The figure below illustrates how to use the APIs. -**Figure 2** Process of using a regulator +**Figure 2** Using regulator driver APIs -![](figures/process-of-using-regulator.png) +![](figures/using-regulator-process.png) #### Opening a Regulator Device Handle @@ -105,7 +106,7 @@ DevHandle RegulatorOpen(const char *name); | name | Name of the target regulator. | | **Return Value**| **Description** | | handle | The regulator device handle is returned if the operation is successful.| -| NULL | The operation fails. | +| NULL | The operation failed. | @@ -155,7 +156,7 @@ int32_t RegulatorEnable(DevHandle handle); | handle | Device handle of the target regulator.| | **Return Value**| **Description** | | 0 | The operation is successful. | -| Negative value | The operation fails. | +| Negative value | The operation failed. | @@ -184,7 +185,7 @@ int32_t RegulatorDisable(DevHandle handle); | handle | Device handle of the target regulator.| | **Return Value**| **Description** | | 0 | The operation is successful. | -| Negative value | The operation fails. | +| Negative value | The operation failed. | ``` int32_t ret; @@ -212,7 +213,7 @@ int32_t RegulatorForceDisable(DevHandle handle); | handle | Device handle of the target regulator.| | **Return Value**| **Description** | | 0 | The operation is successful. | -| Negative value | The operation fails. | +| Negative value | The operation failed. | ``` int32_t ret; @@ -241,7 +242,7 @@ int32_t RegulatorSetVoltage(DevHandle handle, uint32_t minUv, uint32_t maxUv); | maxUv | Maximum voltage to set. | | **Return Value**| **Description** | | 0 | The operation is successful. | -| Negative value | The operation fails. | +| Negative value | The operation failed. | ``` int32_t ret; @@ -272,7 +273,7 @@ int32_t RegulatorGetVoltage(DevHandle handle, uint32_t *voltage); | *voltage | Pointer to the regulator voltage information. | | **Return Value**| **Description** | | 0 | The operation is successful. | -| Negative value | The operation fails. | +| Negative value | The operation failed. | ``` int32_t ret; @@ -302,7 +303,7 @@ int32_t RegulatorSetCurrent(DevHandle handle, uint32_t minUa, uint32_t maxUa); | maxUa | Maximum current to set. | | **Return Value**| **Description** | | 0 | The operation is successful. | -| Negative value | The operation fails. | +| Negative value | The operation failed. | ``` int32_t ret; @@ -332,7 +333,7 @@ int32_t RegulatorGetCurrent(DevHandle handle, uint32_t *regCurrent); | *regCurrent | Pointer to the regulator current information. | | **Return Value** | **Description** | | 0 | The operation is successful. | -| Negative value | The operation fails. | +| Negative value | The operation failed. | ``` int32_t ret; @@ -361,7 +362,7 @@ int32_t RegulatorGetStatus(DevHandle handle, uint32_t *status); | *status | Pointer to the regulator status information. | | **Return Value**| **Description** | | 0 | The operation is successful. | -| Negative value | The operation fails. | +| Negative value | The operation failed. | ``` int32_t ret; diff --git a/en/device-dev/driver/driver-platform-rtc-des.md b/en/device-dev/driver/driver-platform-rtc-des.md index 529546787b0efa2a3f01185d27a0dfc416fcc208..abfde56ba35b4c1b4754bb0e660534d8397c3dba 100644 --- a/en/device-dev/driver/driver-platform-rtc-des.md +++ b/en/device-dev/driver/driver-platform-rtc-des.md @@ -104,12 +104,12 @@ The real-time clock \(RTC\) driver provides precise real time for the operating During the OS startup, the HDF loads the RTC driver based on the configuration file. The RTC driver detects the RTC component and initializes the driver. -[Figure 1](#fig1610020107333) illustrates the process of using an RTC device. +The figure below illustrates how to use the APIs. -**Figure 1** Process of using an RTC device -![](figures/process-of-using-an-rtc-device.png "process-of-using-an-rtc-device") +**Figure 1** Process of using an RTC device +![](figures/using-rtc-process.png "process-of-using-an-rtc-device") -### Creating an RTC Device Handle +### Opening the RTC Device Handle After the RTC driver is loaded, you can use the API provided by the HDF and call APIs of the RTC driver. @@ -138,17 +138,18 @@ DevHandle RtcOpen\(void\);

handle

-

Returns the if the operation is successful.

+

The operation is successful.

NULL

-

The operation fails.

+

The operation failed.

+ ``` DevHandle handle = NULL; @@ -161,7 +162,7 @@ if (handle == NULL) { ### Releasing the RTC Device Handle -You can call the following function to release the RTC device handle, thereby releasing resources of the device: +You can call **RtcClose()** function to release the RTC device handle, thereby releasing resources of the device. void RtcClose\(DevHandle handle\); @@ -186,7 +187,7 @@ void RtcClose\(DevHandle handle\); RtcClose(handle); ``` -### Registering RtcAlarmCallback +### Registering RtcAlarmCallback After the OS is started, call the following function to register **RtcAlarmCallback**, which will be invoked when an alarm is generated at the specified time: @@ -228,7 +229,7 @@ int32\_t RtcRegisterAlarmCallback\(DevHandle handle, enum RtcAlarmIndex alarmInd

Negative value

-

The operation fails.

+

The operation failed.

@@ -257,11 +258,11 @@ if (ret != 0) { } ``` -### Performing RTC-related Operations +### Performing RTC-related Operations - Reading RTC time -Call the following function to read time information from the RTC driver, including the year, month, the day of the week, day, hour, minute, second, and millisecond: +Call the **RtcReadTime()** function to read time information from the RTC driver, including the year, month, the day of the week, day, hour, minute, second, and millisecond. int32\_t RtcReadTime\(DevHandle handle, struct RtcTime \*time\); @@ -295,7 +296,7 @@ int32\_t RtcReadTime\(DevHandle handle, struct RtcTime \*time\);

Negative value

-

The operation fails.

+

The operation failed.

@@ -314,7 +315,7 @@ if (ret != 0) { - Setting RTC time -Call the following function to set the RTC time: +Call the **RtcWriteTime()** function to set the RTC time. int32\_t RtcWriteTime\(DevHandle handle, struct RtcTime \*time\); @@ -348,7 +349,7 @@ int32\_t RtcWriteTime\(DevHandle handle, struct RtcTime \*time\);

Negative value

-

The operation fails.

+

The operation failed.

@@ -378,7 +379,7 @@ if (ret != 0) { - Reading the RTC alarm time -Call the following function to read the alarm time: +Call the **RtcReadAlarm()** function to read the alarm time. int32\_t RtcReadAlarm\(DevHandle handle, enum RtcAlarmIndex alarmIndex, struct RtcTime \*time\); @@ -417,7 +418,7 @@ int32\_t RtcReadAlarm\(DevHandle handle, enum RtcAlarmIndex alarmIndex, struct R

Negative value

-

The operation fails.

+

The operation failed.

@@ -436,7 +437,7 @@ if (ret != 0) { - Setting RTC alarm time -Call the following function to set the RTC alarm time based on the alarm index: +Call the **RtcWriteAlarm()** function to set the RTC alarm time based on the alarm index. int32\_t RtcWriteAlarm\(DevHandle handle, enum RtcAlarmIndex alarmIndex, struct RtcTime \*time\); @@ -475,7 +476,7 @@ int32\_t RtcWriteAlarm\(DevHandle handle, enum RtcAlarmIndex alarmIndex, struct

Negative value

-

The operation fails.

+

The operation failed.

@@ -505,7 +506,7 @@ if (ret != 0) { - Enabling or disabling alarm interrupts -Before performing alarm operations, use the following function to enable alarm interrupts, so that **RtcAlarmCallback** will be called when the alarm is not generated upon a timeout: +Before performing alarm operations, use the **RtcAlarmInterruptEnable()** function to enable alarm interrupts, so that **RtcAlarmCallback** will be called when the alarm is not generated upon a timeout. int32\_t RtcAlarmInterruptEnable\(DevHandle handle, enum RtcAlarmIndex alarmIndex, uint8\_t enable\); @@ -544,7 +545,7 @@ int32\_t RtcAlarmInterruptEnable\(DevHandle handle, enum RtcAlarmIndex alarmInde

Negative value

-

The operation fails.

+

The operation failed.

@@ -562,7 +563,7 @@ if (ret != 0) { - Reading RTC external frequency -Call the following function to read the frequency of the external crystal oscillator connected to the RTC driver: +Call the **RtcGetFreq()** function to read the frequency of the external crystal oscillator connected to the RTC driver. int32\_t RtcGetFreq\(DevHandle handle, uint32\_t \*freq\); @@ -596,7 +597,7 @@ int32\_t RtcGetFreq\(DevHandle handle, uint32\_t \*freq\);

Negative value

-

The operation fails.

+

The operation failed.

@@ -615,7 +616,7 @@ if (ret != 0) { - Setting the frequency of the external crystal oscillator connected to the RTC driver -Call the following function to set the frequency of the external crystal oscillator connected to the RTC driver: +Call the **RtcSetFreq()** function to set the frequency of the external crystal oscillator connected to the RTC driver. int32\_t RtcSetFreq\(DevHandle handle, uint32\_t freq\); @@ -649,7 +650,7 @@ int32\_t RtcSetFreq\(DevHandle handle, uint32\_t freq\);

Negative value

-

The operation fails.

+

The operation failed.

@@ -668,7 +669,7 @@ if (ret != 0) { - Resetting the RTC driver -Call the following function to perform a reset on the RTC driver \(after the reset, the registers are restored to the default values\): +Call the **RtcReset()** function to perform a reset on the RTC driver \(after the reset, the registers are restored to the default values\). int32\_t RtcReset\(DevHandle handle\); @@ -697,7 +698,7 @@ int32\_t RtcReset\(DevHandle handle\);

Negative value

-

The operation fails.

+

The operation failed.

@@ -715,7 +716,7 @@ if (ret != 0) { - Reading the configuration of a custom RTC register -Call the following function to read the configuration of a custom RTC register based on the register index \(one index corresponds to one byte of the configuration value\): +Call the **RtcReadReg()** function to read the configuration of a custom RTC register based on the register index \(one index corresponds to one byte of the configuration value\): int32\_t RtcReadReg\(DevHandle handle, uint8\_t usrDefIndex, uint8\_t \*value\); @@ -754,7 +755,7 @@ int32\_t RtcReadReg\(DevHandle handle, uint8\_t usrDefIndex, uint8\_t \*value\);

Negative value

-

The operation fails.

+

The operation failed.

@@ -774,7 +775,7 @@ if (ret != 0) { - Setting the configuration of a custom RTC register -Call the following function to configure a register based on the specified register index \(one index corresponds to one byte of the configuration value\): +Call the **RtcWriteReg()** function to configure a register based on the specified register index \(one index corresponds to one byte of the configuration value\). int32\_t RtcWriteReg\(DevHandle handle, uint8\_t usrDefIndex, uint8\_t value\); @@ -813,7 +814,7 @@ int32\_t RtcWriteReg\(DevHandle handle, uint8\_t usrDefIndex, uint8\_t value\);

Negative value

-

The operation fails.

+

The operation failed.

diff --git a/en/device-dev/driver/driver-platform-sdio-des.md b/en/device-dev/driver/driver-platform-sdio-des.md index 575148cb787917e5ee5ed005d4416fd39e394194..3957f2a90233180829ba613670f8b31cd071eb43 100644 --- a/en/device-dev/driver/driver-platform-sdio-des.md +++ b/en/device-dev/driver/driver-platform-sdio-des.md @@ -1,4 +1,4 @@ -# SDIO +# SDIO ## Overview @@ -13,8 +13,7 @@ The SDIO bus has two ends, named host and device. All communication starts when - D0-3 signal: four data lines. The DAT1 signal cable is multiplexed as the interrupt line. In 1-bit mode, DAT0 is used to transmit data. In 4-bit mode, DAT0 to DAT3 are used to transmit data. - CMD signal: used by the host to send commands and the device to respond to commands. -**Figure 1** Connections between the host and devices in SDIO - +**Figure 1** Connections between the host and devices in SDIO ![](figures/en-us_image_0000001160971556.png) @@ -149,12 +148,14 @@ The SDIO interface defines a set of common methods for operating an SDIO device, ### How to Use -[Figure 2](#fig1343742311264) illustrates the process of using an SDIO. +The figure below illustrates how to use the APIs. + +**Figure 2** Using SDIO driver APIs -**Figure 2** Process of using an SDIO + -![](figures/en-us_image_0000001206291517.png) +![](figures/using-SDIO-process.png) ### Opening an SDIO Controller diff --git a/en/device-dev/driver/driver-platform-spi-des.md b/en/device-dev/driver/driver-platform-spi-des.md index a8b35d2682b0f9c19afd362b9f84600b2c75cea6..066b92ea231bf86f8a0b2688b1119ef3bd832f84 100644 --- a/en/device-dev/driver/driver-platform-spi-des.md +++ b/en/device-dev/driver/driver-platform-spi-des.md @@ -104,10 +104,10 @@ SPI communication is usually initiated by the SPI controller and is operated as ### How to Use -[Figure 2](#fig1586912310348) shows the process of using an SPI device. +The figure below illustrates how to use the APIs. -**Figure 2** Process of using an SPI device -![](figures/process-of-using-an-spi-device.png "process-of-using-an-spi-device") +**Figure 2** Using SPI driver APIs +![](figures/using-spi-process.png "process-of-using-an-spi-device") ### Obtaining an SPI Device Handle diff --git a/en/device-dev/driver/driver-platform-uart-des.md b/en/device-dev/driver/driver-platform-uart-des.md index 37d4c34d6dbd91440b72f0b502d0b8439379ba14..20340bfd49d68136a9ca711cca35ca5c2cdb0834 100644 --- a/en/device-dev/driver/driver-platform-uart-des.md +++ b/en/device-dev/driver/driver-platform-uart-des.md @@ -103,10 +103,10 @@ The UART interface defines a set of common functions for operating a UART port, ### How to Use -[Figure 3](#fig99673244388) shows the process of using a UART device. +The figure below illustrates how to use the APIs. -**Figure 3** Process of using a UART device -![](figures/process-of-using-a-uart-device.png "process-of-using-a-uart-device") +**Figure 3** Using UART driver APIs +![](figures/using-uart-process.png "process-of-using-a-uart-device") ### Obtaining a UART Device Handle diff --git a/en/device-dev/driver/driver-platform-watchdog-des.md b/en/device-dev/driver/driver-platform-watchdog-des.md index 2a9b44765c44f637aa97b9c1aab8867da5ad12e6..deb85133a3dde4f11cfb03762f4f4fd9d656d51b 100644 --- a/en/device-dev/driver/driver-platform-watchdog-des.md +++ b/en/device-dev/driver/driver-platform-watchdog-des.md @@ -77,10 +77,10 @@ A watchdog, also called a watchdog timer, is a hardware timing device. If an err ### How to Use -[Figure 1](#fig430533913392) illustrates the process of using a watchdog. +The figure below illustrates how to use the APIs. -**Figure 1** Process of using a watchdog -![](figures/process-of-using-a-watchdog.png "process-of-using-a-watchdog") +**Figure 1** Using watchdog driver APIs +![](figures/using-watchdog-process.png "process-of-using-a-watchdog") ### Opening a Watchdog diff --git a/en/device-dev/driver/figures/ADC_flowchart.png b/en/device-dev/driver/figures/ADC_flowchart.png deleted file mode 100644 index cc8e6494c3ddcf5def7962020210e127f68aec5d..0000000000000000000000000000000000000000 Binary files a/en/device-dev/driver/figures/ADC_flowchart.png and /dev/null differ diff --git a/en/device-dev/driver/figures/process-of-using-DAC.png b/en/device-dev/driver/figures/process-of-using-DAC.png deleted file mode 100644 index 7a62db53a3683922d4033ae4cde5e29d3d50fa22..0000000000000000000000000000000000000000 Binary files a/en/device-dev/driver/figures/process-of-using-DAC.png and /dev/null differ diff --git a/en/device-dev/driver/figures/process-of-using-PWM.png b/en/device-dev/driver/figures/process-of-using-PWM.png deleted file mode 100644 index 7d2c8befd805532d94f9742cc3b28248db5f76e3..0000000000000000000000000000000000000000 Binary files a/en/device-dev/driver/figures/process-of-using-PWM.png and /dev/null differ diff --git a/en/device-dev/driver/figures/process-of-using-a-gpio.png b/en/device-dev/driver/figures/process-of-using-a-gpio.png deleted file mode 100644 index 69b779798c759a78a0139ed052a6f6187ba83660..0000000000000000000000000000000000000000 Binary files a/en/device-dev/driver/figures/process-of-using-a-gpio.png and /dev/null differ diff --git a/en/device-dev/driver/figures/process-of-using-a-mipi-dsi-device.png b/en/device-dev/driver/figures/process-of-using-a-mipi-dsi-device.png deleted file mode 100644 index 3e7f6c13b5c7a7b76c472f856e84c855f5380435..0000000000000000000000000000000000000000 Binary files a/en/device-dev/driver/figures/process-of-using-a-mipi-dsi-device.png and /dev/null differ diff --git a/en/device-dev/driver/figures/process-of-using-a-uart-device.png b/en/device-dev/driver/figures/process-of-using-a-uart-device.png deleted file mode 100644 index 6c1997d120e03bc66658b7bb8107c8605c8ad5ce..0000000000000000000000000000000000000000 Binary files a/en/device-dev/driver/figures/process-of-using-a-uart-device.png and /dev/null differ diff --git a/en/device-dev/driver/figures/process-of-using-a-watchdog.png b/en/device-dev/driver/figures/process-of-using-a-watchdog.png deleted file mode 100644 index c2826f6fff6ba9092c0ccb3f9f7bf91e3c23a094..0000000000000000000000000000000000000000 Binary files a/en/device-dev/driver/figures/process-of-using-a-watchdog.png and /dev/null differ diff --git a/en/device-dev/driver/figures/process-of-using-an-i2c-device.png b/en/device-dev/driver/figures/process-of-using-an-i2c-device.png deleted file mode 100644 index 7eda062addfe07011d62763355028964a6fb511f..0000000000000000000000000000000000000000 Binary files a/en/device-dev/driver/figures/process-of-using-an-i2c-device.png and /dev/null differ diff --git a/en/device-dev/driver/figures/process-of-using-an-rtc-device.png b/en/device-dev/driver/figures/process-of-using-an-rtc-device.png deleted file mode 100644 index fdba48eb6ad079dbf0ca1d8675903703b94e4ab0..0000000000000000000000000000000000000000 Binary files a/en/device-dev/driver/figures/process-of-using-an-rtc-device.png and /dev/null differ diff --git a/en/device-dev/driver/figures/process-of-using-an-spi-device.png b/en/device-dev/driver/figures/process-of-using-an-spi-device.png deleted file mode 100644 index aba1a6b3053728121092e634d5ed007b51fbb6fc..0000000000000000000000000000000000000000 Binary files a/en/device-dev/driver/figures/process-of-using-an-spi-device.png and /dev/null differ diff --git a/en/device-dev/driver/figures/process-of-using-regulator.png b/en/device-dev/driver/figures/process-of-using-regulator.png deleted file mode 100644 index 6dddc62b20eba787ee3ca469718a930e2174ca51..0000000000000000000000000000000000000000 Binary files a/en/device-dev/driver/figures/process-of-using-regulator.png and /dev/null differ diff --git a/en/device-dev/driver/figures/using-ADC-process.png b/en/device-dev/driver/figures/using-ADC-process.png new file mode 100644 index 0000000000000000000000000000000000000000..e4390a3d7cb3d7ac985f1703d49c02217a0696d2 Binary files /dev/null and b/en/device-dev/driver/figures/using-ADC-process.png differ diff --git a/en/device-dev/driver/figures/using-DAC-process.png b/en/device-dev/driver/figures/using-DAC-process.png new file mode 100644 index 0000000000000000000000000000000000000000..9b3d2336d8462d46c06866491876d3b4d06a0258 Binary files /dev/null and b/en/device-dev/driver/figures/using-DAC-process.png differ diff --git a/en/device-dev/driver/figures/using-GPIO-process.png b/en/device-dev/driver/figures/using-GPIO-process.png new file mode 100644 index 0000000000000000000000000000000000000000..adfdc259524a89b0aca5d99ecc183c516f92f25f Binary files /dev/null and b/en/device-dev/driver/figures/using-GPIO-process.png differ diff --git a/en/device-dev/driver/figures/using-I2C-process.png b/en/device-dev/driver/figures/using-I2C-process.png new file mode 100644 index 0000000000000000000000000000000000000000..cb92407de96a64d9aab0425f80bf824616a32d3d Binary files /dev/null and b/en/device-dev/driver/figures/using-I2C-process.png differ diff --git a/en/device-dev/driver/figures/process-of-using-MIPI-CSI.png b/en/device-dev/driver/figures/using-MIPI-CSI-process.png similarity index 100% rename from en/device-dev/driver/figures/process-of-using-MIPI-CSI.png rename to en/device-dev/driver/figures/using-MIPI-CSI-process.png diff --git a/en/device-dev/driver/figures/using-MIPI-DSI-process.png b/en/device-dev/driver/figures/using-MIPI-DSI-process.png new file mode 100644 index 0000000000000000000000000000000000000000..eaab316ff409064eee64fc06d4f3cc5508221fd1 Binary files /dev/null and b/en/device-dev/driver/figures/using-MIPI-DSI-process.png differ diff --git a/en/device-dev/driver/figures/using-PWM-process.png b/en/device-dev/driver/figures/using-PWM-process.png new file mode 100644 index 0000000000000000000000000000000000000000..3d70498418c65576fb3dd79046ccb7793a291eab Binary files /dev/null and b/en/device-dev/driver/figures/using-PWM-process.png differ diff --git a/en/device-dev/driver/figures/using-RTC-process.png b/en/device-dev/driver/figures/using-RTC-process.png new file mode 100644 index 0000000000000000000000000000000000000000..850703fbe375ae95d5deb2774aa38d0a45e1ee7f Binary files /dev/null and b/en/device-dev/driver/figures/using-RTC-process.png differ diff --git a/en/device-dev/driver/figures/using-SDIO-process.png b/en/device-dev/driver/figures/using-SDIO-process.png new file mode 100644 index 0000000000000000000000000000000000000000..d7da373cb17d2ee02ebc9a98cfba156cde761d87 Binary files /dev/null and b/en/device-dev/driver/figures/using-SDIO-process.png differ diff --git a/en/device-dev/driver/figures/using-SPI-process.png b/en/device-dev/driver/figures/using-SPI-process.png new file mode 100644 index 0000000000000000000000000000000000000000..a8c02b7b99fa7db78e05d7f38bf7ea05fc54401a Binary files /dev/null and b/en/device-dev/driver/figures/using-SPI-process.png differ diff --git a/en/device-dev/driver/figures/using-UART-process.png b/en/device-dev/driver/figures/using-UART-process.png new file mode 100644 index 0000000000000000000000000000000000000000..c0457b5feef6eeb6c1c845aa0755666b135eb448 Binary files /dev/null and b/en/device-dev/driver/figures/using-UART-process.png differ diff --git a/en/device-dev/driver/figures/process-of-using-pin.png b/en/device-dev/driver/figures/using-pin-process.png similarity index 100% rename from en/device-dev/driver/figures/process-of-using-pin.png rename to en/device-dev/driver/figures/using-pin-process.png diff --git a/en/device-dev/driver/figures/using-regulator-process.png b/en/device-dev/driver/figures/using-regulator-process.png new file mode 100644 index 0000000000000000000000000000000000000000..da251499bb7973d46026d6e317627b6ed98120c4 Binary files /dev/null and b/en/device-dev/driver/figures/using-regulator-process.png differ diff --git a/en/device-dev/driver/figures/using-watchdog-process.png b/en/device-dev/driver/figures/using-watchdog-process.png new file mode 100644 index 0000000000000000000000000000000000000000..6b99d28fd621e222bd6873ada2c47405a4f55a42 Binary files /dev/null and b/en/device-dev/driver/figures/using-watchdog-process.png differ diff --git a/en/device-dev/kernel/Readme-EN.md b/en/device-dev/kernel/Readme-EN.md index 3d8321373b9c1c0b873ad0833b5f3e0fe3b059a8..b7b289d4c0a9814fed92f8829618077b7588f2ad 100644 --- a/en/device-dev/kernel/Readme-EN.md +++ b/en/device-dev/kernel/Readme-EN.md @@ -27,7 +27,7 @@ - Kernel Debugging - [Memory Debugging](kernel-mini-memory-debug.md) - [Memory Information Statistics](kernel-mini-memory-debug-mes.md) - - [Memory Leak Check](kernel-mini-imemory-debug-det.md) + - [Memory Leak Check](kernel-mini-memory-debug-det.md) - [Memory Corruption Check](kernel-mini-memory-debug-cet.md) - [Exception Debugging](kernel-mini-memory-exception.md) - [Trace](kernel-mini-memory-trace.md) @@ -180,5 +180,4 @@ - [Enhanced Swap](kernel-standard-mm-eswap.md) - [Task Scheduling](kernel-standard-sched.md) - [Related Thread Group](kernel-standard-sched-rtg.md) - - [Lightweight CPU Isolation](kernel-standard-sched-cpuisolation.md) - \ No newline at end of file + - [Lightweight CPU Isolation](kernel-standard-sched-cpuisolation.md) \ No newline at end of file diff --git a/en/device-dev/kernel/kernel-mini-basic-memory-dynamic.md b/en/device-dev/kernel/kernel-mini-basic-memory-dynamic.md index 54d04f222e05feee34b86955208de2221753845f..c24f1b1496cb59258b51c53259b8a15e1e75a2fd 100644 --- a/en/device-dev/kernel/kernel-mini-basic-memory-dynamic.md +++ b/en/device-dev/kernel/kernel-mini-basic-memory-dynamic.md @@ -4,19 +4,19 @@ Dynamic memory management allows memory blocks of any size to be allocated from a large contiguous memory \(memory pool or heap memory\) configured in the system based on user demands when memory resources are sufficient. The memory block can be released for further use when not required. Compared with static memory management, dynamic memory management allows memory allocation on demand but causes fragmentation of memory. -The dynamic memory of the OpenHarmony LiteOS-M has optimized the memory space partitioning based on the Two-Level Segregate Fit \(TLSF\) algorithm to achieve higher performance and minimize fragmentation. [Figure 1](#fig1179964042818) shows the core algorithm of the dynamic memory. +The dynamic memory of the OpenHarmony LiteOS-M has optimized the memory space partitioning based on the Two-Level Segregate Fit \(TLSF\) algorithm to achieve higher performance and minimize fragmentation. The figure below shows the core algorithm of the dynamic memory. **Figure 1** Dynamic memory algorithm for mini systems ![](figures/dynamic-memory-algorithm-for-mini-systems.png "dynamic-memory-algorithm-for-mini-systems") -Multiple free lists are used for management based on the size of the free memory block. The free memory blocks are divided into two parts: \[4, 127\] and \[27, 231\], as indicated by the size class in [Figure 1](#fig1179964042818). +Multiple free lists are used for management based on the size of the free memory block. The free memory blocks are divided into two parts: \[4, 127\] and \[27, 231\], as indicated by the size class in the above figure. -1. The memory in the range of \[4, 127\] \(lower part in [Figure 1](#fig1179964042818)\) is divided into 31 parts. The size of the memory block corresponding to each part is a multiple of 4 bytes. Each part corresponds to a free list and a bit that indicates whether the free list is empty. The value **1** indicates that the free list is not empty. There are 31 bits corresponding to the 31 memory parts in the range of \[4, 127\]. -2. The memory greater than 127 bytes is managed in power of two increments. The size of each range is \[2^n, 2^\(n+1\)-1\], where n is an integer in \[7, 30\]. This range is divided into 24 parts, each of which is further divided into 8 second-level \(L2\) ranges, as shown in Size Class and Size SubClass in the upper part of [Figure 1](#fig1179964042818). Each L2 range corresponds to a free list and a bit that indicates whether the free list is empty. There are a total of 192 \(24 x 8\) L2 ranges, corresponding to 192 free lists and 192 bits. +1. The memory in the range of \[4, 127\] \(lower part in the above figure) is divided into 31 parts. The size of the memory block corresponding to each part is a multiple of 4 bytes. Each part corresponds to a free list and a bit that indicates whether the free list is empty. The value **1** indicates that the free list is not empty. There are 31 bits corresponding to the 31 memory parts in the range of \[4, 127\]. +2. The memory greater than 127 bytes is managed in power of two increments. The size of each range is \[2^n, 2^\(n+1\)-1\], where n is an integer in \[7, 30\]. This range is divided into 24 parts, each of which is further divided into 8 second-level \(L2\) ranges, as shown in Size Class and Size SubClass in the upper part of the above figure. Each L2 range corresponds to a free list and a bit that indicates whether the free list is empty. There are a total of 192 \(24 x 8\) L2 ranges, corresponding to 192 free lists and 192 bits. For example, insert 40-byte free memory to a free list. The 40-byte free memory corresponds to the 10th free list in the range of \[40, 43\], and the 10th bit indicates the use of the free list. The system inserts the 40-byte free memory to the 10th free list and determines whether to update the bitmap flag. When 40-byte memory is requested, the system obtains the free list corresponding to the memory block of the requested size based on the bitmap flag, and then obtains a free memory node from the free list. If the size of the allocated node is greater than the memory requested, the system splits the node and inserts the remaining node to the free list. If 580-byte free memory needs to be inserted to a free list, the 580-byte free memory corresponds to the 47th \(31 + 2 x 8\) free list in L2 range \[2^9, 2^9+2^6\], and the 47th bit indicates the use of the free list. The system inserts the 580-byte free memory to the 47th free list and determines whether to update the bitmap flag. When 580-byte memory is requested, the system obtains the free list corresponding to the memory block of the requested size based on the bitmap flag, and then obtains a free memory node from the free list. If the size of the allocated node is greater than the memory requested, the system splits the node and inserts the remaining node to the free list. If the corresponding free list is empty, the system checks for a free list meeting the requirements in a larger memory range. In actual application, the system can locate the free list that meets the requirements at a time. -[Figure 2](#fig10997102213017) shows the memory management structure. +The figure below shows the memory management structure. **Figure 2** Dynamic memory management structure for mini systems ![](figures/dynamic-memory-management-structure-for-mini-systems.png "dynamic-memory-management-structure-for-mini-systems") @@ -30,7 +30,7 @@ For example, insert 40-byte free memory to a free list. The 40-byte free memory There are three types of nodes: free node, used node, and end node. Each memory node maintains the size and use flag of the memory node and a pointer to the previous memory node in the memory pool. The free nodes and used nodes have a data area, but the end node has no data area. -The off-chip physical memory needs to be used because the on-chip RAMs of some chips cannot meet requirements. The OpenHarmony LiteOS-M kernel can logically combine multiple discontiguous memory regions so that users are unaware of the discontiguous memory regions in the underlying layer. The OpenHarmony LiteOS-M kernel memory module inserts discontiguous memory regions into a free list as free memory nodes and marks the discontiguous parts as virtual memory nodes that have been used. In this way, the discontinuous memory regions are logically combined as a unified memory pool. [Figure 3](#fig18471556115917) shows how the discontiguous memory regions are logically integrated. +The off-chip physical memory needs to be used because the on-chip RAMs of some chips cannot meet requirements. The OpenHarmony LiteOS-M kernel can logically combine multiple discontiguous memory regions so that users are unaware of the discontiguous memory regions in the underlying layer. The OpenHarmony LiteOS-M kernel memory module inserts discontiguous memory regions into a free list as free memory nodes and marks the discontiguous parts as virtual memory nodes that have been used. In this way, the discontinuous memory regions are logically combined as a unified memory pool. The figure below shows how the discontiguous memory regions are logically integrated. **Figure 3** Integrating discontiguous memory regions ![](figures/integrating-discontiguous-memory-regions.png "integrating-discontiguous-memory-regions") diff --git a/en/device-dev/kernel/kernel-mini-overview.md b/en/device-dev/kernel/kernel-mini-overview.md index 3ff627c00e0d0569b018b1a15a4113632cc2e7b7..7b86f1a82028e03366eb3441d6257eb7791764c3 100644 --- a/en/device-dev/kernel/kernel-mini-overview.md +++ b/en/device-dev/kernel/kernel-mini-overview.md @@ -4,7 +4,7 @@ The OpenHarmony LiteOS-M kernel is a lightweight operating system \(OS\) kernel designed for the IoT field. It features small size, low power consumption, and high performance. The LiteOS-M kernel has simple code structure, including the minimum function set, kernel abstraction layer \(KAL\), optional components, and project directory. It supports the Hardware Driver Foundation \(HDF\), which provides unified driver standards and access mode for device vendors to simplify porting of drivers and allow one-time development for multi-device deployment. -The OpenHarmony LiteOS-M kernel architecture consists of the hardware layer and hardware-irrelevant layers, as shown in [Figure 1](#fig1287712172318). The hardware layer is classified based on the compiler toolchain and chip architecture, and provides a unified Hardware Abstraction Layer \(HAL\) interface to improve hardware adaptation and facilitate the expansion of various types of AIoT hardware and compilation toolchains. The other modules are irrelevant to the hardware. The basic kernel module provides basic kernel capabilities. The extended modules provide capabilities of components, such as the network and file systems, as well as exception handling and debug tools. The KAL provides unified standard APIs. +The OpenHarmony LiteOS-M kernel architecture consists of the hardware layer and hardware-irrelevant layers, as shown in the figure below. The hardware layer is classified based on the compiler toolchain and chip architecture, and provides a unified Hardware Abstraction Layer \(HAL\) interface to improve hardware adaptation and facilitate the expansion of various types of AIoT hardware and compilation toolchains. The other modules are irrelevant to the hardware. The basic kernel module provides basic kernel capabilities. The extended modules provide capabilities of components, such as the network and file systems, as well as exception handling and debug tools. The KAL provides unified standard APIs. **Figure 1** Kernel architecture ![](figures/kernel-architecture.png "kernel-architecture") @@ -48,11 +48,11 @@ The CPU architecture includes two layers: general architecture definition layer -LiteOS-M supports mainstream architectures, such as ARM Cortex-M3, ARM Cortex-M4, ARM Cortex-M7, ARM Cortex-M33, and RISC-V. If you need to expand the CPU architecture, see [Chip Architecture Adaptation](../porting/porting-chip-kernel-overview.md#section137431650339). +LiteOS-M supports mainstream architectures, such as ARM Cortex-M3, ARM Cortex-M4, ARM Cortex-M7, ARM Cortex-M33, and RISC-V. If you need to expand the CPU architecture, see [Chip Architecture Adaptation](../porting/porting-chip-kernel-overview.md#section137431650339). ### Working Principles -Configure the system clock and number of ticks per second in the **target\_config.h** file of the development board. Configure the task, memory, inter-process communication \(IPC\), and exception handling modules based on service requirements. When the system boots, the modules are initialized based on the configuration. The kernel startup process includes peripheral initialization, system clock configuration, kernel initialization, and OS boot. For details, see [Figure 2](#fig74259220441). +Configure the system clock and number of ticks per second in the **target\_config.h** file of the development board. Configure the task, memory, inter-process communication \(IPC\), and exception handling modules based on service requirements. When the system boots, the modules are initialized based on the configuration. The kernel startup process includes peripheral initialization, system clock configuration, kernel initialization, and OS boot, as shown in the figure below. **Figure 2** Kernel startup process ![](figures/kernel-startup-process.png "kernel-startup-process") diff --git a/en/device-dev/porting/Readme-EN.md b/en/device-dev/porting/Readme-EN.md index 581aaf0bfcb8cdfda65617c9025c45cb4651a4ef..086ee39c3207b6666c7d9caef509c51c8cdfdebd 100644 --- a/en/device-dev/porting/Readme-EN.md +++ b/en/device-dev/porting/Readme-EN.md @@ -60,7 +60,7 @@ The download steps for other resources are the same as those in the mainline ver ## SoC Porting Cases -- [Mini System SoC Porting Cases](porting-minichip-cases.md) +- Mini System SoC Porting Cases - [Mini-System Devices with Screens — Bestechnic SoC Porting Case](porting-bes2600w-on-minisystem-display-demo.md) - [Combo Solution – ASR Chip Porting Case](porting-asr582x-combo-demo.md) diff --git a/en/device-dev/porting/standard-system-porting-guide.md b/en/device-dev/porting/standard-system-porting-guide.md index bb56dacfd1b8c575d6c5eab01b1f02c23440ee03..98caa433d6170a9d52f0cdbf4e61f55d77d78afa 100644 --- a/en/device-dev/porting/standard-system-porting-guide.md +++ b/en/device-dev/porting/standard-system-porting-guide.md @@ -8,11 +8,11 @@ This document uses the process of porting a development board named **MyProduct ### Defining a Product -Create a config.json file in the directory with the name "//vendor/MyProductVendor/{product_name}. This file is used to describe the SoC used by the product and the required subsystems. configure the file as follows: +Create a **config.json** file in the directory **//vendor/MyProductVendor/*{product_name}***. This file is used to describe the SoC used by the product and the required subsystems. + +For example, if **product_name** is **MyProduct**, configure the **//vendor/MyProductVendor/MyProduct/config.json** file as follows: -//vendor/MyProductVendor/MyProduct/config.json - ``` { "product_name": "MyProduct", @@ -39,29 +39,29 @@ Create a config.json file in the directory with the name "//vendor/MyProductVend The main configurations are as follows: -product_name:The product name.Required +**product_name**: product name. This parameter is required. -version:version.Required +**version**: version. This parameter is required. -type:Configured at the system level, select from (mini, small, standard).Required +**type**: system level, which can be **mini**, **small**, or **standard**. This parameter is required. -target_cpu :The CPU type of the device (depending on the actual situation, the target_cpu here may also be arm64, riscv, x86, etc..).Required +**target_cpu**: CPU type of the device (depending on the actual situation, the target_cpu here may also be arm64, riscv, x86, etc..). This parameter is required. -ohos_version:Operating system version.Optional +**ohos_version**: operating system version. This parameter is optional. -device_company:device manufacturer name.Required +**device_company**: device manufacturer name. This parameter is required. -board:Board name.Required +**board**: board name. This parameter is required. -enable_ramdisk:Whether to start ramdisk.Required +**enable_ramdisk**: whether to enable the RAM disk. This parameter is required. -kernel_type and kernel_version: kernel_type with kernel_version is fixed in the standard and does not need to be written.Optional +**kernel_type** and **kernel_version**: fixed in the standard system. They are optional. -subsystems:The subsystem that the system needs to be enabled. Subsystems can simply understand a piece of function that is built independently. Required +**subsystems**: subsystem to enable. A subsystem can be treated as an independently built functional block. This parameter is required. -product_company:Not reflected in the configuration, but in the directory name, the next directory of the vendor is product_company, build.gn script can still be accessed. +**product_company**: device manufacturer name. It is not set in the configuration, but in the directory name, next to the vendor name. It can be accessed from **build.gn script**. -You can find available subsystems in **//build/subsystem\_config.json**. You can also customize subsystems. +You can find predefined subsystems in **//build/subsystem\_config.json**. You can also customize subsystems. You are advised to copy the configuration file of Hi3516D V300 and delete the **hisilicon\_products** subsystem, which is used to compile the kernel for Hi3516D V300. diff --git a/en/device-dev/quick-start/Readme-EN.md b/en/device-dev/quick-start/Readme-EN.md index 1fb06af53be58306f25c68033f8db5dbd811e53f..2afa83a8d1a6e0ea5e79f97018044f86e1be3a1f 100644 --- a/en/device-dev/quick-start/Readme-EN.md +++ b/en/device-dev/quick-start/Readme-EN.md @@ -33,7 +33,7 @@ - [Burning](quickstart-lite-steps-hi3861-burn.md) - [Networking](quickstart-lite-steps-hi3861-netconfig.md) - [Debugging and Verification](quickstart-lite-steps-hi3861-debug.md) - - [Running](quickstart-lite-steps-hi3816-running.md) + - [Running](quickstart-lite-steps-hi3861-running.md) - Hi3516 Development Board - [Setting Up the Hi3516 Development Board Environment](quickstart-lite-steps-hi3516-setting.md) - [Writing a Hello World Program](quickstart-lite-steps-hi3516-application-framework.md) diff --git a/en/device-dev/quick-start/quickstart-ide-lite-env-setup-win-ubuntu.md b/en/device-dev/quick-start/quickstart-ide-lite-env-setup-win-ubuntu.md index b16ef9ebb0e6886773f01d1481b86f51720d1511..f274a5f0ee452334be8fa93eac3844c62c79e73c 100644 --- a/en/device-dev/quick-start/quickstart-ide-lite-env-setup-win-ubuntu.md +++ b/en/device-dev/quick-start/quickstart-ide-lite-env-setup-win-ubuntu.md @@ -20,8 +20,6 @@ In the Windows+Ubuntu hybrid development environment, you can enjoy the benefits ## Setting Up the Ubuntu Development Environment -The setup procedure varies, depending on whether you need a GUI. If you need a GUI, you need to install Visual Studio Code. In this case, follow the instructions in [Setting Up the Ubuntu Development Environment](https://device.harmonyos.com/en/docs/documentation/guide/ide-install-ubuntu-0000001072959308). If you do not need a GUI, perform the steps below: - 1. Make sure the Ubuntu shell environment is **bash**. 1. Run the following command and check whether the command output is **bash**. If the command output is not **bash**, go to step 2. diff --git a/en/device-dev/quick-start/quickstart-lite-steps-hi3816-running.md b/en/device-dev/quick-start/quickstart-lite-steps-hi3861-running.md similarity index 100% rename from en/device-dev/quick-start/quickstart-lite-steps-hi3816-running.md rename to en/device-dev/quick-start/quickstart-lite-steps-hi3861-running.md diff --git a/en/device-dev/quick-start/quickstart-lite-steps-hi3861.md b/en/device-dev/quick-start/quickstart-lite-steps-hi3861.md index d91f35a59f47a33ca413733901908cbd221964f6..0f637821f518c0edcced32f369eb09eb594990c7 100644 --- a/en/device-dev/quick-start/quickstart-lite-steps-hi3861.md +++ b/en/device-dev/quick-start/quickstart-lite-steps-hi3861.md @@ -14,4 +14,5 @@ - **[Debugging and Verification](quickstart-lite-steps-hi3861-debug.md)** -- **[Running](quickstart-lite-steps-hi3816-running.md)** +- **[Running](quickstart-lite-steps-hi3861-running.md)** + diff --git a/en/device-dev/subsystems/Readme-EN.md b/en/device-dev/subsystems/Readme-EN.md index 3a88076442ee79d3184f6e683441d2ffae480813..d42e46d92f01eee9d49fc68f1115492f0726dee9 100644 --- a/en/device-dev/subsystems/Readme-EN.md +++ b/en/device-dev/subsystems/Readme-EN.md @@ -80,7 +80,7 @@ - [syspara Module](subsys-boot-syspara.md) - [FAQs](subsys-boot-faqs.md) - [Reference](subsys-boot-ref.md) -- [Test](subsys-testguide-test.md) +- [Test Case Development](subsys-testguide-test.md) - DFX - [DFX Overview](subsys-dfx-overview.md) - [HiLog Development](subsys-dfx-hilog-rich.md) @@ -96,8 +96,9 @@ - [HiDumper Development](subsys-dfx-hidumper.md) - [HiChecker Development](subsys-dfx-hichecker.md) - [FaultLogger Development](subsys-dfx-faultlogger.md) -- [R&D Tools](subsys-toolchain.md) - - [bytrace Usage Guidelines](subsys-toolchain-bytrace-guide.md) - - [hdc\_stds Usage Guidelines](subsys-toolchain-hdc-guide.md) - - [hiperf Usage Guidelines](subsys-toolchain-hiperf.md) -- [XTS](subsys-xts-guide.md) \ No newline at end of file +- R&D Tools + - [bytrace](subsys-toolchain-bytrace-guide.md) + - [hdc\_std](subsys-toolchain-hdc-guide.md) + - [hiperf](subsys-toolchain-hiperf.md) +- [XTS Test Case Development](subsys-xts-guide.md) + diff --git a/en/device-dev/subsystems/subsys-build-standard-large.md b/en/device-dev/subsystems/subsys-build-standard-large.md index 8dc0d3f4b08c9df0b1138d69ab3355bec787cce1..588d41c97447e31a06b67f21e226f27e00183efe 100644 --- a/en/device-dev/subsystems/subsys-build-standard-large.md +++ b/en/device-dev/subsystems/subsys-build-standard-large.md @@ -61,19 +61,19 @@ The process to build OpenHarmony is as follows: ### Directory Structure ``` -/build # Primary directory -├── config # Build configuration items +/build # Primary directory +├── config # Build configuration items ├── core │ └── gn # Build entry BUILD.gn configuration -├── loader # Loader of module configuration, which also generates a template for the module -├── ohos # Configuration of the process for building and packaging OpenHarmony +├── loader # Loader of module configuration, which also generates a template for the module +├── ohos # Configuration of the process for building and packaging OpenHarmony │ ├── kits # Build and packaging templates and processing flow for kits │ ├── ndk # NDK template and processing flow │ ├── notice # Notice template and processing flow │ ├── packages # Distribution packaging template and processing flow │ ├── sa_profile # SA template and processing flow │ ├── sdk # SDK template and processing flow, which contains the module configuration in the SDK -│ └── testfwk # Processing flow related to the test +│ └── testfwk # Processing flow related to the test ├── scripts # Build-related Python script ├── templates # C/C++ build templates └── toolchain # Toolchain configuration @@ -207,7 +207,7 @@ The process to build OpenHarmony is as follows: 2. Add the module to the product configuration file. - Add the module to the product configuration file **//vendor/{product_company}/{product-name}/config.json。**. + Add the module to the product configuration file **//vendor/{product_company}/{product-name}/config.json**. Add "subsystem\_examples:partA" to the product configuration file. **partA** will be built and packaged into the distribution. diff --git a/en/device-dev/subsystems/subsys-testguide-test.md b/en/device-dev/subsystems/subsys-testguide-test.md index 3440111dfcfbcfaf79b016d4a690aed4b52f7e29..1e27562840bcefc707cbb4916470d7da2eda25a0 100644 --- a/en/device-dev/subsystems/subsys-testguide-test.md +++ b/en/device-dev/subsystems/subsys-testguide-test.md @@ -1,4 +1,4 @@ -# Test +# Test Case Development OpenHarmony provides a comprehensive auto-test framework for designing test cases. Detecting defects in the development process can improve code quality. This document describes how to use the OpenHarmony test framework. diff --git a/en/device-dev/subsystems/subsys-xts-guide.md b/en/device-dev/subsystems/subsys-xts-guide.md index 8edb14f97ee25a560587fbe9b875e5b9aaf5d50e..8e3413be4f6cbc230bbf470e360fe8ffc713e1b7 100644 --- a/en/device-dev/subsystems/subsys-xts-guide.md +++ b/en/device-dev/subsystems/subsys-xts-guide.md @@ -1,4 +1,4 @@ -# XTS +# XTS Test Case Development ## Introduction diff --git a/en/device-dev/subsystems/subsys.md b/en/device-dev/subsystems/subsys.md index 1b2c9674870709f5ae43d34292298387a16dda28..7eb175c7a40640aae1e0bc1de699179be0e91b23 100644 --- a/en/device-dev/subsystems/subsys.md +++ b/en/device-dev/subsystems/subsys.md @@ -14,9 +14,9 @@ - **[Telephony](subsys-tel.md)** - **[Security](subsys-security.md)** - **[Startup](subsys-boot.md)** -- **[Test](subsys-testguide-test.md)** +- **[Test Case Development](subsys-testguide-test.md)** - **[DFX](subsys-dfx.md)** - **[R&D Tools](subsys-toolchain.md)** -- **[XTS](subsys-xts-guide.md)** +- **[XTS Test Case Development](subsys-xts-guide.md)** diff --git a/en/device-dev/website.md b/en/device-dev/website.md index 8f6c8f6d8321de1b4895b7c7227cb873ac137788..ebb4bafa881a3b91dcd436c6a2b4594101744f27 100644 --- a/en/device-dev/website.md +++ b/en/device-dev/website.md @@ -35,7 +35,7 @@ - [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-hi3816-running.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-application-framework.md) @@ -341,40 +341,40 @@ - [Driver Configuration Management](driver/driver-hdf-manage.md) - [HDF Development Example](driver/driver-hdf-sample.md) - Platform Driver Development - - [ADC](driver-platform-adc-develop.md) - - [DAC](driver-platform-dac-develop.md) - - [GPIO](driver-platform-gpio-develop.md) - - [HDMI](driver-platform-hdmi-develop.md) - - [I2C](driver-platform-i2c-develop.md) - - [I3C](driver-platform-i3c-develop.md) - - [MIPI CSI](driver-platform-mipicsi-develop.md) - - [MIPI DSI](driver-platform-mipidsi-develop.md) - - [MMC](driver-platform-mmc-develop.md) - - [PIN](driver-platform-pin-develop.md) - - [PWM](driver-platform-pwm-develop.md) - - [Regulator](driver-platform-regulator-develop.md) - - [RTC](driver-platform-rtc-develop.md) - - [SDIO](driver-platform-sdio-develop.md) - - [SPI](driver-platform-spi-develop.md) - - [UART](driver-platform-uart-develop.md) - - [WatchDog](driver-platform-watchdog-develop.md) + - [ADC](driver/driver-platform-adc-develop.md) + - [DAC](driver/driver-platform-dac-develop.md) + - [GPIO](driver/driver-platform-gpio-develop.md) + - [HDMI](driver/driver-platform-hdmi-develop.md) + - [I2C](driver/driver-platform-i2c-develop.md) + - [I3C](driver/driver-platform-i3c-develop.md) + - [MIPI CSI](driver/driver-platform-mipicsi-develop.md) + - [MIPI DSI](driver/driver-platform-mipidsi-develop.md) + - [MMC](driver/driver-platform-mmc-develop.md) + - [PIN](driver/driver-platform-pin-develop.md) + - [PWM](driver/driver-platform-pwm-develop.md) + - [Regulator](driver/driver-platform-regulator-develop.md) + - [RTC](driver/driver-platform-rtc-develop.md) + - [SDIO](driver/driver-platform-sdio-develop.md) + - [SPI](driver/driver-platform-spi-develop.md) + - [UART](driver/driver-platform-uart-develop.md) + - [WatchDog](driver/driver-platform-watchdog-develop.md) - Platform Driver Usage - - [ADC](driver-platform-adc-des.md) - - [DAC](driver-platform-dac-des.md) - - [GPIO](driver-platform-gpio-des.md) - - [HDMI](driver-platform-hdmi-des.md) - - [I2C](driver-platform-i2c-des.md) - - [I3C](driver-platform-i3c-des.md) - - [MIPI CSI](driver-platform-mipicsi-des.md) - - [MIPI DSI](driver-platform-mipidsi-des.md) - - [PIN](driver-platform-pin-des.md) - - [PWM](driver-platform-pwm-des.md) - - [Regulator](driver-platform-regulator-des.md) - - [RTC](driver-platform-rtc-des.md) - - [SDIO](driver-platform-sdio-des.md) - - [SPI](driver-platform-spi-des.md) - - [UART](driver-platform-uart-des.md) - - [WatchDog](driver-platform-watchdog-des.md) + - [ADC](driver/driver-platform-adc-des.md) + - [DAC](driver/driver-platform-dac-des.md) + - [GPIO](driver/driver-platform-gpio-des.md) + - [HDMI](driver/driver-platform-hdmi-des.md) + - [I2C](driver/driver-platform-i2c-des.md) + - [I3C](driver/driver-platform-i3c-des.md) + - [MIPI CSI](driver/driver-platform-mipicsi-des.md) + - [MIPI DSI](driver/driver-platform-mipidsi-des.md) + - [PIN](driver/driver-platform-pin-des.md) + - [PWM](driver/driver-platform-pwm-des.md) + - [Regulator](driver/driver-platform-regulator-des.md) + - [RTC](driver/driver-platform-rtc-des.md) + - [SDIO](driver/driver-platform-sdio-des.md) + - [SPI](driver/driver-platform-spi-des.md) + - [UART](driver/driver-platform-uart-des.md) + - [WatchDog](driver/driver-platform-watchdog-des.md) - Peripheral Driver Usage - [LCD](driver/driver-peripherals-lcd-des.md) - [Touchscreen](driver/driver-peripherals-touch-des.md) @@ -520,7 +520,7 @@ - [Development Example for Peripheral Drivers](guide/device-outerdriver-demo.md) - Debugging - - [Test](subsystems/subsys-testguide-test.md) + - [Test Case Development](subsystems/subsys-testguide-test.md) - Debugging Tools - [bytrace](subsystems/subsys-toolchain-bytrace-guide.md) - [hdc\_std](subsystems/subsys-toolchain-hdc-guide.md) diff --git a/en/readme.md b/en/readme.md index 5ca900639a5e2c02862d44681ece181b503cf386..e220bd152b32ff7cdf34c000d283acfab619fcba 100644 --- a/en/readme.md +++ b/en/readme.md @@ -8,6 +8,6 @@ This repository stores a complete range of OpenHarmony documentation. The conten - [Release Notes](release-notes/Readme.md) - [Subsystems](./readme) - OpenHarmony Contribution - - [Contribution Guide](contribute/how-to-contribute.md) + - [Contribution Guide](contribute/contribution-guide.md) - [OpenHarmony Part and API Design Reference](./design) diff --git a/en/readme/SAMGR.md b/en/readme/SAMGR.md index 8978b54a33b01f01b4da64deaabace8d1867f5a7..be89cb571dcacb5407fed7e8d0d6765121968acc 100644 --- a/en/readme/SAMGR.md +++ b/en/readme/SAMGR.md @@ -19,7 +19,7 @@ The System Ability Manager (SAMGR) subsystem implements the system service frame ├── safwk # System ability framework ├── samgr # System ability manager ├── safwk_lite # Lightweight foundation process -├── samgr_lite # Lightweight system ability manager +└── samgr_lite # Lightweight system ability manager ``` ## Repositories Involved diff --git a/en/readme/misc-services.md b/en/readme/misc-services.md index 3cafe421bcb3e2e91be47a46bc936f708427ba16..8b9c5295f58503f63563afe57347534660a3350f 100755 --- a/en/readme/misc-services.md +++ b/en/readme/misc-services.md @@ -4,7 +4,7 @@ The Misc services subsystem provides APIs for setting the system time. -**Figure 1** Subsystem architecture +**Figure 1** Subsystem architecture ![](figures/subsystem-architecture.png "subsystem-architecture") ## Directory Structure diff --git a/en/website.md b/en/website.md index 7a5374affa4e0848b8a963ec98521e72e7be5bf6..4ff9a1de38b77e2bd53fb61d8366aaa17b4c0155 100644 --- a/en/website.md +++ b/en/website.md @@ -6,12 +6,12 @@ - OpenHarmony 3.x Releases - [OpenHarmony v3.1 Release (2022-03-30)](release-notes/OpenHarmony-v3.1-release.md) - [OpenHarmony v3.1 Beta (2021-12-31)](release-notes/OpenHarmony-v3.1-beta.md) - - [OpenHarmony v3.0.1 LTS (2022-01-12)](release-notes/OpenHarmony-v3.0.1-LTS.md) -- [OpenHarmony v3.0 LTS (2021-09-30)](release-notes/OpenHarmony-v3.0-LTS.md) - + - [OpenHarmony v3.0.3 LTS (2022-04-08)](release-notes/OpenHarmony-v3.0.3-LTS.md) + - [OpenHarmony v3.0 LTS (2021-09-30)](release-notes/OpenHarmony-v3.0-LTS.md) + - OpenHarmony 2.x Releases - [OpenHarmony v2.2 beta2 (2021-08-04)](release-notes/OpenHarmony-v2.2-beta2.md) - - [OpenHarmony 2.0 Canary (2021-06-01)](release-notes/OpenHarmony-2-0-Canary.md) + - [OpenHarmony 2.0 Canary (2021-06-01)](release-notes/OpenHarmony-2-0-Canary.md) - OpenHarmony 1.x Releases - [OpenHarmony v1.1.4 LTS (2022-02-11)](release-notes/OpenHarmony-v1-1-4-LTS.md) - [OpenHarmony v1.1.3 LTS (2021-09-30)](release-notes/OpenHarmony-v1-1-3-LTS.md) diff --git a/zh-cn/application-dev/ability/fa-dataability.md b/zh-cn/application-dev/ability/fa-dataability.md index 627089036adcff07a0c70369d7134ef9185c85c2..e9fd630224f21b76c4ebd019d130ba8ee44aea9d 100644 --- a/zh-cn/application-dev/ability/fa-dataability.md +++ b/zh-cn/application-dev/ability/fa-dataability.md @@ -32,6 +32,14 @@ Data提供方可以自定义数据的增、删、改、查,以及文件打开 创建Data的代码示例如下: ```javascript + import dataAbility from '@ohos.data.dataAbility' + import dataRdb from '@ohos.data.rdb' + + const TABLE_NAME = 'book' + const STORE_CONFIG = { name: 'book.db' } + const SQL_CREATE_TABLE = 'CREATE TABLE IF NOT EXISTS book(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, introduction TEXT NOT NULL)' + let rdbStore: dataRdb.RdbStore = undefined + export default { onInitialized(abilityInfo) { console.info('DataAbility onInitialized, abilityInfo:' + abilityInfo.bundleName) @@ -50,7 +58,7 @@ Data提供方可以自定义数据的增、删、改、查,以及文件打开 for (let i = 0;i < valueBuckets.length; i++) { console.info('DataAbility batch insert i=' + i) if (i < valueBuckets.length - 1) { - rdbStore.insert(TABLE_NAME, valueBuckets[i], (num: number) => { + rdbStore.insert(TABLE_NAME, valueBuckets[i], (err: any, num: number) => { console.info('DataAbility batch insert ret=' + num) }) } else { @@ -118,6 +126,10 @@ Data提供方可以自定义数据的增、删、改、查,以及文件打开 工具接口类对象DataAbilityHelper相关接口可参考[DataAbilityHelper模块](../reference/apis/js-apis-dataAbilityHelper.md)。 ```js // 作为参数传递的Uri,与config中定义的Uri的区别是多了一个"/",是因为作为参数传递的uri中,在第二个与第三个"/"中间,存在一个DeviceID的参数 + import featureAbility from '@ohos.ability.featureAbility' + import ohos_data_ability from '@ohos.data.dataAbility' + import ohos_data_rdb from '@ohos.data.rdb' + var urivar = "dataability:///com.ix.DataAbility" var DAHelper = featureAbility.acquireDataAbilityHelper( urivar @@ -137,7 +149,7 @@ Data提供方可以自定义数据的增、删、改、查,以及文件打开 urivar, valuesBucket, (error, data) => { - expect(typeof(data)).assertEqual("number") + console.log("DAHelper insert result: " + data) } ); ``` @@ -156,7 +168,7 @@ Data提供方可以自定义数据的增、删、改、查,以及文件打开 urivar, da, (error, data) => { - expect(typeof(data)).assertEqual("number") + console.log("DAHelper delete result: " + data) } ); ``` @@ -176,7 +188,7 @@ Data提供方可以自定义数据的增、删、改、查,以及文件打开 valuesBucket, da, (error, data) => { - expect(typeof(data)).assertEqual("number") + console.log("DAHelper update result: " + data) } ); ``` @@ -197,7 +209,7 @@ Data提供方可以自定义数据的增、删、改、查,以及文件打开 valArray, da, (error, data) => { - expect(typeof(data)).assertEqual("object") + console.log("DAHelper query result: " + data) } ); ``` @@ -217,7 +229,7 @@ Data提供方可以自定义数据的增、删、改、查,以及文件打开 urivar, cars, (error, data) => { - expect(typeof(data)).assertEqual("number") + console.log("DAHelper batchInsert result: " + data) } ); ``` @@ -241,12 +253,12 @@ Data提供方可以自定义数据的增、删、改、查,以及文件打开 valuesBucket: {"executeBatch" : "value1",}, predicates: da, expectedCount:0, - PredicatesBackReferences: {}, + predicatesBackReferences: null, interrupted:true, } ], (error, data) => { - expect(typeof(data)).assertEqual("object") + console.log("DAHelper executeBatch result: " + data) } ); ``` @@ -265,7 +277,7 @@ Data提供方可以自定义数据的增、删、改、查,以及文件打开 }, predicates: da, expectedCount:0, - PredicatesBackReferences: {}, + predicatesBackReferences: null, interrupted:true, } ] diff --git a/zh-cn/application-dev/ability/fa-serviceability.md b/zh-cn/application-dev/ability/fa-serviceability.md index 188a87b7f68eead3458b0a579f932b173af57d43..f5605b17f9aa711e941138e5e9f14ff0bea19b5c 100644 --- a/zh-cn/application-dev/ability/fa-serviceability.md +++ b/zh-cn/application-dev/ability/fa-serviceability.md @@ -32,6 +32,7 @@ }, onConnect(want) { console.log('ServiceAbility OnConnect'); + return null; }, onDisconnect(want) { console.log('ServiceAbility OnDisConnect'); @@ -78,12 +79,12 @@ Ability为开发者提供了startAbility()方法来启动另外一个Ability。 ```javascript import featureAbility from '@ohos.ability.featureAbility'; -let promise = await featureAbility.startAbility( +let promise = featureAbility.startAbility( { want: { - bundleName: "com.jstest.serviceability", - abilityName: "com.jstest.serviceability.MainAbility", + bundleName: "com.jstest.service", + abilityName: "com.jstest.service.ServiceAbility", }, } ); @@ -110,6 +111,8 @@ let promise = await featureAbility.startAbility( 创建连接本地Service回调实例的代码示例如下: ```javascript +import prompt from '@system.prompt' + let mRemote; function onConnectCallback(element, remote){ console.log('onConnectLocalService onConnectDone element: ' + element); @@ -154,8 +157,8 @@ function onFailedCallback(code){ import featureAbility from '@ohos.ability.featureAbility'; let connId = featureAbility.connectAbility( { - bundleName: "com.jstest.serviceability", - abilityName: "com.jstest.serviceability.MainAbility", + bundleName: "com.jstest.service", + abilityName: "com.jstest.service.ServiceAbility", }, { onConnect: onConnectCallback, @@ -223,6 +226,8 @@ export default { 创建连接远程Service回调实例的代码示例如下: ```ts +import prompt from '@system.prompt' + let mRemote; function onConnectCallback(element, remote){ console.log('onConnectRemoteService onConnectDone element: ' + element); @@ -264,7 +269,10 @@ function onFailedCallback(code){ ```ts import deviceManager from '@ohos.distributedHardware.deviceManager'; + +//dmClass具体实现请参考:相关实例 分布式Demo 章节中的实现 let dmClass; + function getRemoteDeviceId() { if (typeof dmClass === 'object' && dmClass != null) { let list = dmClass.getTrustedDeviceListSync(); @@ -327,9 +335,6 @@ async function RequestPermission() { let context = featureAbility.getContext(); context.requestPermissionsFromUser(requestPermissions, 1, (data)=>{ console.info("data:" + JSON.stringify(data)); - console.info("data requestCode:" + data.requestCode); - console.info("data permissions:" + data.permissions); - console.info("data authResults:" + data.authResults); }); console.info('RequestPermission end'); } diff --git a/zh-cn/application-dev/ability/wantagent.md b/zh-cn/application-dev/ability/wantagent.md index 260fa41f19dcc9e0c7c4fe5cd3b9593b835bdecc..fe51abab01097b1308480e524d0f454664f03d2a 100644 --- a/zh-cn/application-dev/ability/wantagent.md +++ b/zh-cn/application-dev/ability/wantagent.md @@ -1,72 +1,88 @@ # WantAgent开发指导 -### 简介 -wantAgent封装了一个指定行为的意图,可以通过wantAgent.trigger接口主动触发,也可以通过与通知绑定被动触发。 +### 场景简介 +WantAgent封装了一个行为意图信息,可以通过WantAgent.trigger接口主动触发,也可以通过与通知绑定被动触发。 -具体的行为包括:启动ability和发布公共事件。 - -### 场景介绍 -通过wantAgent,拉起另外一个ability +具体的行为包括:启动Ability和发布公共事件。 ### 接口说明 | 接口名 | 接口描述 | | ---------------------------------------------------------------------------------------------- | ----------- | -| wantAgent.getWantAgentInfo(info: WantAgentInfo, callback: AsyncCallback\) | 创建wantAgent对象(callback) | -| wantAgent.getWantAgent(info: WantAgentInfo): Promise\; | 创建wantAgent对象(promise) | -| commonEvent.trigger(agent: WantAgent, triggerInfo: TriggerInfo, callback?: Callback\) | 触发wantAgent | +| getWantAgentInfo(info: WantAgentInfo, callback: AsyncCallback\) | 以AsyncCallback形式创建WantAgent对象 | +| getWantAgent(info: WantAgentInfo): Promise\ | 以Promise形式创建WantAgent对象 | +| trigger(agent: WantAgent, triggerInfo: TriggerInfo, callback?: Callback\) | 触发WantAgent | ### 开发步骤 1. 导入WantAgent模块。 -```javascript -import wantAgent from '@ohos.wantAgent'; -``` + ``` + import wantAgent from '@ohos.wantAgent'; + ``` + +2. 创建拉起Ability的WantAgentInfo信息,详细的WantAgentInfo信息数据类型及包含的参数请见[WantAgentInfo文档](../reference/apis/js-apis-wantAgent.md#wantagentinfo)介绍。 -2. 创建WantAgentInfo信息,详细的WantAgentInfo信息数据类型及包含的参数请见[WantAgentInfo文档](../reference/apis/js-apis-wantAgent.md#WantAgentInfo)介绍。 + ``` + private wantAgentObj = null //用于保存创建成功的wantAgent对象,后续使用其完成触发的动作。 + + //wantAgentInfo + var wantAgentInfo = { + wants: [ + { + deviceId: "", + bundleName: "com.example.test", + abilityName: "com.example.test.MainAbility", + action: "", + entities: [], + uri: "", + parameters: {} + } + ], + operationType: OperationType.START_ABILITY, + requestCode: 0, + wantAgentFlags:[WantAgentFlags.CONSTANT_FLAG] + } + ``` -```javascript -private wantAgentObj = null //用于保存创建成功的wantAgent对象,后续使用其完成触发的动作 +3. 创建发布公共事件的WantAgentInfo信息 -//wantAgentInfo -var wantAgentInfo = { - wants: [ - { - deviceId: "", - bundleName: "com.example.test", - abilityName: "com.example.test.MainAbility", - action: "", - entities: [], - uri: "", - parameters: {} - } - ], - operationType: OperationType.START_ABILITY, - requestCode: 0, - wantAgentFlags:[WantAgentFlags.CONSTANT_FLAG] -} -``` + ``` + private wantAgentObj = null //用于保存创建成功的WantAgent对象,后续使用其完成触发的动作。 + + //wantAgentInfo + var wantAgentInfo = { + wants: [ + { + action: "event_name", // 设置事件名 + parameters: {} + } + ], + operationType: OperationType.SEND_COMMON_EVENT, + requestCode: 0, + wantAgentFlags:[WantAgentFlags.CONSTANT_FLAG] + } + ``` -3. 创建wantAgent,保存返回的wantAgent对象wantAgentObj,用于执行后续触发操作。 +4. 创建WantAgent,保存返回的WantAgent对象wantAgentObj,用于执行后续触发操作。 -```javascript -//创建wantAgent -wantAgent.getWantAgent(wantAgentInfo, (err, wantAgentObj) => { - if (err.code) { - console.error("[WantAgent]getWantAgent err=" + JSON.stringify(err)) - } else { - console.log("[WantAgent]getWantAgent success") - this.wantAgentObj = wantAgentObj - } -}) -``` + ``` + //创建WantAgent + wantAgent.getWantAgent(wantAgentInfo, (err, wantAgentObj) => { + if (err.code) { + console.error("[WantAgent]getWantAgent err=" + JSON.stringify(err)) + } else { + console.log("[WantAgent]getWantAgent success") + this.wantAgentObj = wantAgentObj + } + }) + ``` -4. 触发wantAgent +5. 触发WantAgent -``` -//触发wantAgent -var triggerInfo = { - code:0 -} -wantAgent.trigger(wantAgentObj, triggerInfo, (completeData) => { - console.log("[WantAgent]getWantAgent success, completeData: ", + JSON.stringify(completeData)) -}) -``` \ No newline at end of file + ``` + //触发WantAgent + var triggerInfo = { + code:0 + } + wantAgent.trigger(wantAgentObj, triggerInfo, (completeData) => { + console.log("[WantAgent]getWantAgent success, completeData: ", + JSON.stringify(completeData)) + }) + ``` diff --git a/zh-cn/application-dev/media/Readme-CN.md b/zh-cn/application-dev/media/Readme-CN.md index 9c39d85302086efca820bb40678674cbfe77f8ae..0188fdbe591a03cc547891d1bb97afdbb4eed64e 100755 --- a/zh-cn/application-dev/media/Readme-CN.md +++ b/zh-cn/application-dev/media/Readme-CN.md @@ -15,3 +15,6 @@ - 图片 - [图片开发指导](image.md) + +- 相机 + - [相机开发指导](camera.md) \ No newline at end of file diff --git a/zh-cn/application-dev/media/camera.md b/zh-cn/application-dev/media/camera.md new file mode 100644 index 0000000000000000000000000000000000000000..161cc8864bf06ab02716480d155609bd13ea042f --- /dev/null +++ b/zh-cn/application-dev/media/camera.md @@ -0,0 +1,472 @@ +# 相机开发指导 + +## 场景介绍 + +相机模块支持相机相关基础功能的开发,主要包括预览、拍照、录像等。本文将对相机各种基础功能的开发进行介绍说明。 + +## 开发步骤 + +### 接口说明 + +详细API含义请参考:[相机管理API文档](../reference/apis/js-apis-camera.md) + +### 全流程场景 + +包含流程:创建实例、参数设置、会话管理、拍照、录像、释放资源等。 + +Xcomponent创建方法可参考:[XComponent创建方法](#xcomponent创建方法) + +拍照保存接口可参考:[图片处理API文档](../reference/apis/js-apis-image.md) + +#### 创建实例 + +```js +import camera from '@ohos.multimedia.camera' +import image from '@ohos.multimedia.image' +import media from '@ohos.multimedia.media' +import featureAbility from '@ohos.ability.featureAbility' + +//创建CameraManager对象 +let cameraManager +await camera.getCameraManager(globalThis.Context, (err, manager) => { + if (err) { + console.error('Failed to get the CameraManager instance ${err.message}'); + return; + } + console.log('Callback returned with the CameraManager instance'); + cameraManager = manager +}) + +//注册回调函数监听相机状态变化,获取状态变化的相机信息 +cameraManager.on('cameraStatus', (cameraStatusInfo) => { + console.log('camera : ' + cameraStatusInfo.camera.cameraId); + console.log('status: ' + cameraStatusInfo.status); +}) + +//获取相机列表 +let cameraArray +await cameraManager.getCameras((err, cameras) => { + if (err) { + console.error('Failed to get the cameras. ${err.message}'); + return; + } + console.log('Callback returned with an array of supported cameras: ' + cameras.length); + cameraArray = cameras +}) + + for(let cameraIndex = 0; cameraIndex < cameraArray.length; cameraIndex) { + console.log('cameraId : ' + cameraArray[cameraIndex].cameraId) //获取相机ID + console.log('cameraPosition : ' + cameraArray[cameraIndex].cameraPosition) //获取相机位置 + console.log('cameraType : ' + cameraArray[cameraIndex].cameraType) //获取相机类型 + console.log('connectionType : ' + cameraArray[cameraIndex].connectionType) //获取相机连接类型 + } + + //创建相机输入流 + let cameraInput + await cameraManager.createCameraInput(cameraArray[0].cameraId).then((input) => { + console.log('Promise returned with the CameraInput instance'); + cameraInput = input +}) + +//创建预览输出流 +let previewOutput +camera.createPreviewOutput((globalThis.surfaceId), (err, output) => { + if (err) { + console.error('Failed to create the PreviewOutput instance. ${err.message}'); + return; + } + console.log('Callback returned with previewOutput instance'); + previewOutput = output +}); + +//创建ImageReceiver对象,并设置照片参数 +let imageReceiver = await image.createImageReceiver(1920, 1080, 4, 8) +//获取照片显示SurfaceId +let photoSurfaceId = await imageReceiver.getReceivingSurfaceId() +//创建拍照输出流 +let photoOutput +camera.createPhotoOutput((photoSurfaceId), (err, output) => { + if (err) { + console.error('Failed to create the PhotoOutput instance. ${err.message}'); + return; + } + console.log('Callback returned with the PhotoOutput instance.'); + photoOutput = output +}); + +//创建视频录制的参数 +let videoProfile = { + audioBitrate : 48000, + audioChannels : 2, + audioCodec : 'audio/mp4a-latm', + audioSampleRate : 48000, + fileFormat : 'mp4', + videoBitrate : 48000, + videoCodec : 'video/mp4v-es', + videoFrameWidth : 640, + videoFrameHeight : 480, + videoFrameRate : 30 +} +let videoConfig = { + audioSourceType : 1, + videoSourceType : 0, + profile : videoProfile, + url : 'file:///data/media/01.mp4', + orientationHint : 0, + location : { latitude : 30, longitude : 130 }, +} + +//创建录像输出流 +let videoRecorder +await media.createVideoRecorder().then((recorder) => { + console.log('createVideoRecorder called') + videoRecorder = recorder +}) +//设置视频录制的参数 +await videoRecorder.prepare(videoConfig) +//获取录像SurfaceId +await videoRecorder.getInputSurface().then((id) => { + console.log('getInputSurface called') + videoSurfaceId = id +}) +``` +videoRecorder详细创建方法可参考:[视频录制开发指导](./video-recorder.md) +```js +//创建VideoOutput对象 +let videoOutput +camera.createVideoOutput((surfaceId), (err, output) => { + if (err) { + console.error('Failed to create the VideoOutput instance. ${err.message}'); + return; + } + console.log('Callback returned with the VideoOutput instance'); + videoOutput = output +}); + +``` + +#### 参数设置 + +```js +//判断设备是否支持闪光灯 +let flashStatus +await cameraInput.hasFlash().then((status) => { + console.log('Promise returned with the flash light support status:' + status); + flashStatus = status +}) +if(flashStatus) { + //判断是否支持自动闪光灯模式 + let flashModeStatus + cameraInput.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO, (err, status) => { + if (err) { + console.error('Failed to check whether the flash mode is supported. ${err.message}'); + return; + } + console.log('Callback returned with the flash mode support status: ' + status); + flashModeStatus = status + }) + if(flashModeStatus) { + //设置自动闪光灯模式 + cameraInput.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO, (err) => { + if (err) { + console.error('Failed to set the flash mode ${err.message}'); + return; + } + console.log('Callback returned with the successful execution of setFlashMode.'); + }) + } +} + +//判断是否支持连续自动变焦模式 +let focusModeStatus +cameraInput.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_CONTINUOUS_AUTO, (err, status) => { + if (err) { + console.error('Failed to check whether the focus mode is supported. ${err.message}'); + return; + } + console.log('Callback returned with the focus mode support status: ' + status); + focusModeStatus = status +}) +if(focusModeStatus) { + //设置连续自动变焦模式 + cameraInput.setFocusMode(camera.FocusMode.FOCUS_MODE_CONTINUOUS_AUTO, (err) => { + if (err) { + console.error('Failed to set the focus mode ${err.message}'); + return; + } + console.log('Callback returned with the successful execution of setFocusMode.'); + }) +} + +//获取相机支持的可变焦距比范围 +let zoomRatioRange +cameraInput.getZoomRatioRange((err, range) => { + if (err) { + console.error('Failed to get the zoom ratio range. ${err.message}'); + return; + } + console.log('Callback returned with zoom ratio range: ' + range.length); + zoomRatioRange = range +}) + +//设置可变焦距比 +cameraInput.setZoomRatio(zoomRatioRange[0], (err) => { + if (err) { + console.error('Failed to set the zoom ratio value ${err.message}'); + return; + } + console.log('Callback returned with the successful execution of setZoomRatio.'); +}) +``` + +#### 会话管理 + +##### 创建会话 + +```js +//创建Context对象 +let context = featureAbility.getContext() + +//创建会话 +let captureSession +await camera.createCaptureSession((context), (err, session) => { + if (err) { + console.error('Failed to create the CaptureSession instance. ${err.message}'); + return; + } + console.log('Callback returned with the CaptureSession instance.' + session); + captureSession = session +}); + +//开始配置会话 +await captureSession.beginConfig((err) => { + if (err) { + console.error('Failed to start the configuration. ${err.message}'); + return; + } + console.log('Callback invoked to indicate the begin config success.'); +}); + +//向会话中添加相机输入流 +await captureSession.addInput(cameraInput, (err) => { + if (err) { + console.error('Failed to add the CameraInput instance. ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the CameraInput instance is added.'); +}); + +//向会话中添加预览输入流 +await captureSession.addOutput(previewOutput, (err) => { + if (err) { + console.error('Failed to add the PreviewOutput instance ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the PreviewOutput instance is added.'); +}); + +//向会话中添加拍照输出流 +await captureSession.addOutput(photoOutput, (err) => { + if (err) { + console.error('Failed to add the PhotoOutput instance ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the PhotoOutput instance is added.'); +}); + +//提交会话配置 +await captureSession.commitConfig((err) => { + if (err) { + console.error('Failed to commit the configuration. ${err.message}'); + return; + } + console.log('Callback invoked to indicate the commit config success.'); +}); + +//启动会话 +await captureSession.start().then(() => { + console.log('Promise returned to indicate the session start success.'); +}) +``` + +##### 切换会话 + +```js +//停止当前会话 +await captureSession.stop((err) => { + if (err) { + console.error('Failed to stop the session ${err.message}'); + return; + } + console.log('Callback invoked to indicate the session stop success.'); +}); + +//开始配置会话 +await captureSession.beginConfig((err) => { + if (err) { + console.error('Failed to start the configuration. ${err.message}'); + return; + } + console.log('Callback invoked to indicate the begin config success.'); +}); + +//从会话中移除拍照输出流 +await captureSession.removeOutput(photoOutput, (err) => { + if (err) { + console.error('Failed to remove the PhotoOutput instance. ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the PhotoOutput instance is removed.'); +}); + +//向会话中添加录像输出流 +await captureSession.addOutput(videoOutput, (err) => { + if (err) { + console.error('Failed to add the VideoOutput instance ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the VideoOutput instance is added.'); +}); + +//提交会话配置 +await captureSession.commitConfig((err) => { + if (err) { + console.error('Failed to commit the configuration. ${err.message}'); + return; + } + console.log('Callback invoked to indicate the commit config success.'); +}); + +//启动会话 +await captureSession.start().then(() => { + console.log('Promise returned to indicate the session start success.'); +}) +``` + +#### 拍照 + +```js +let settings = { + quality: camera.QualityLevel.QUALITY_LEVEL_HIGH //设置图片质量高 + rotation: camera.ImageRotation.ROTATION_0, //设置图片旋转角度0 +} +//使用当前拍照设置进行拍照 +photoOutput.capture(settings, (err) => { + if (err) { + console.error('Failed to capture the photo ${err.message}'); + return; + } + console.log('Callback invoked to indicate the photo capture request success.'); +}); +``` + +#### 录像 + +```js +//启动录像输出流 +videoOutput.start((err) => { + if (err) { + console.error('Failed to start the video output ${err.message}'); + return; + } + console.log('Callback invoked to indicate the video output start success.'); +}); + +//开始录像 +await videoRecorder.start().then(() => { + console.info('videoRecorder start success'); +} + +//停止录像 +await videoRecorder.stop().then(() => { + console.info('stop success'); +} + +//停止录像输出流 +await videoOutput.stop((err) => { + if (err) { + console.error('Failed to stop the video output ${err.message}'); + return; + } + console.log('Callback invoked to indicate the video output stop success.'); +}); +``` + +#### 释放资源 + +```js +//停止当前会话 +await captureSession.stop((err) => { + if (err) { + console.error('Failed to stop the session ${err.message}'); + return; + } + console.log('Callback invoked to indicate the session stop success.'); +}); +//释放相机输入流 +await cameraInput.release((err) => { + if (err) { + console.error('Failed to release the CameraInput instance ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the CameraInput instance is released successfully.'); +}); +//释放预览输出流 +await previewOutput.release((err) => { + if (err) { + console.error('Failed to release the PreviewOutput instance ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the PreviewOutput instance is released successfully.'); +}); +//释放拍照输出流 +await photoOutput.release((err) => { + if (err) { + console.error('Failed to release the PhotoOutput instance ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the PhotoOutput instance is released successfully.'); +}); +//释放录像输出流 +await videoOutput.release((err) => { + if (err) { + console.error('Failed to release the VideoOutput instance ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the VideoOutput instance is released successfully.'); +}); +//释放会话 +await captureSession.release((err) => { + if (err) { + console.error('Failed to release the CaptureSession instance ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the CaptureSession instance is released successfully.'); +}); +``` + +#### XComponent创建方法 +预览画面显示需要获取SurfaceId + +```js +mXComponentController: XComponentController = new XComponentController //创建XComponentController + +build() { + Flex() { + XComponent({ //创建XComponent + id: '', + type: 'surface', + libraryname: '', + controller: this.mXComponentController + }) + .onload(() => { //设置onload回调 + //设置Surface宽高(1920*1080) + this.mXComponentController.setXComponentSurfaceSize({surfaceWidth:1920,surfaceHeight:1080}) + //获取Surface ID + globalThis.surfaceId = mXComponentController.getXComponentSurfaceId() + }) + .width('1920px') //设置XComponent宽度 + .height('1080px') //设置XComponent高度 + } +} +``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-Context.md b/zh-cn/application-dev/reference/apis/js-apis-Context.md index a019b4968ef3cd42b1b5e497fa9360892e3cd739..5ded8f0e02c5a92ec5b41166e485988e3e72b60d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-Context.md +++ b/zh-cn/application-dev/reference/apis/js-apis-Context.md @@ -6,10 +6,11 @@ ## 导入模块 ```js -import featureAbility from '@ohos.ability.featureAbility' -import bundle from '@ohos.bundle' +import Context from "@ohos.app.context"; ``` +## 使用说明 + Context对象是在featureAbility中创建实例,并通过featureAbility的getContext()接口返回,因此在使用Context时,必须导入@ohos.ability.featureAbility库。示例如下: ```js diff --git a/zh-cn/application-dev/reference/apis/js-apis-ability-context.md b/zh-cn/application-dev/reference/apis/js-apis-ability-context.md index 91155f36f486238c642c406636e6d80ae48310a5..81e4dacaf4e484d2f7a3822ffabed8d635932b54 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-ability-context.md +++ b/zh-cn/application-dev/reference/apis/js-apis-ability-context.md @@ -3,17 +3,17 @@ > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - Ability的上下文环境,继承自Context。 +## 导入模块 +```js +import AbilityContext from '@ohos.application.abilityContext' +``` ## 使用说明 - 在使用AbilityContext的功能前,需要通过Ability子类实例获取。 - - ```js import Ability from '@ohos.application.Ability' class MainAbility extends Ability { diff --git a/zh-cn/application-dev/reference/apis/js-apis-abilityrunninginfo.md b/zh-cn/application-dev/reference/apis/js-apis-abilityrunninginfo.md index 967165a14dea9741c2432716a5f03fe507400b38..a3dd7c921e7dba9e0f6db1a618b0bcedfa9f6246 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-abilityrunninginfo.md +++ b/zh-cn/application-dev/reference/apis/js-apis-abilityrunninginfo.md @@ -6,7 +6,11 @@ Ability运行相关信息。 +## 导入模块 +```js +import AbilityRunningInfo from '@ohos.application.abilityRunningInfo'; +``` ## 使用说明 diff --git a/zh-cn/application-dev/reference/apis/js-apis-abilitystagecontext.md b/zh-cn/application-dev/reference/apis/js-apis-abilitystagecontext.md index 5bf1ffba7de3ded2a797be4db301ae7452aa96af..9542eaf22ac2587ec2c80f616ad77d985680df84 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-abilitystagecontext.md +++ b/zh-cn/application-dev/reference/apis/js-apis-abilitystagecontext.md @@ -6,6 +6,11 @@ AbilityStage的上下文环境,继承自[Context](js-apis-application-context.md)。 +## 导入模块 + +```js +import AbilityStageContext from '@ohos.application.abilityStageContext'; +``` ## 使用说明 diff --git a/zh-cn/application-dev/reference/apis/js-apis-accessibility.md b/zh-cn/application-dev/reference/apis/js-apis-accessibility.md index 7d3076a1c53ab8f84d5aac56cf6677ba774a155f..b10175b813f6d459b0033aab306c00ba31138c3e 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-accessibility.md +++ b/zh-cn/application-dev/reference/apis/js-apis-accessibility.md @@ -266,6 +266,26 @@ off(type: 'styleChange', callback?: Callback<CaptionsStyle>): void; | endIndex | number | 是 | 是 | 画面显示条目的结束序号。 | | itemCount | number | 是 | 是 | 条目总数。 | +### 方法 + +#### constructor + +constructor(jsonObject) + +构造函数。 + +- 参数: + + | 参数名 | 参数类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | jsonObject | string | 是 | 创建对象所需要的 JSON 格式字符串。 | + +- 示例 + + ```typescript + let eventInfo = new accessibility.EventInfo({"type":"click","bundleName":"com.example.MyApplication","triggerAction":"click"}) + ``` + ## EventType 无障碍事件类型。 @@ -310,15 +330,9 @@ off(type: 'styleChange', callback?: Callback<CaptionsStyle>): void; | -------- | -------- | | add | 添加窗口的窗口变化事件。 | | remove | 一个窗口被删除的窗口变化事件。 | -| title | 窗口标题已更改的窗口变化事件。 | | bounds | 窗口边界已更改的窗口变化事件。 | -| layer | 窗口层级发生变化的窗口变化事件。 | | active | 窗口变为活动或不活动的窗口变化事件。 | | focus | 窗口焦点发生变化的窗口变化事件。 | -| accessibilityFocus | 窗口无障碍焦点发生变化的窗口更改事件。 | -| parent | 父窗口已更改的窗口变化事件。 | -| children | 子窗口已更改的窗口变化事件。 | -| pip | 窗口进入或退出画中画(PIP)模式的窗口变化事件。 | ## accessibility.getAbilityLists diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-MissionSnapshot.md b/zh-cn/application-dev/reference/apis/js-apis-application-MissionSnapshot.md index 7327a29524cffc8b3db346b5dd1210b578bf2b3b..52d7863e98bd03e9962f1479a7cbc70763433e56 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-application-MissionSnapshot.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-MissionSnapshot.md @@ -10,13 +10,18 @@ ## 导入模块 +``` +import MissionSnapshot from "@ohos.application.missionSnapshot"; +``` +## 使用说明 + +使用前需要提前引入对应模块。 ``` import { ElementName } from '../bundle/elementName'; import { image } from '../@ohos.multimedia.image'; ``` - ## MissionSnapshot 表示任务对应的任务快照的枚举。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-Want.md b/zh-cn/application-dev/reference/apis/js-apis-application-Want.md index 4a6cbf9e813e32e3de6ed004fed329dadb7a2ea1..a982d6794454eb0cf25bef3192187ae303e2ff63 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-Want.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-Want.md @@ -28,4 +28,4 @@ import Want from '@ohos.application.Want'; | action | 只读 | string | 否 | 表示action选项描述。 | | parameters | 只读 | {[key: string]: any} | 否 | 表示WantParams描述。 | | entities | 只读 | Array\ | 否 | 表示entities相关描述。 | -| moduleName9 | 只读 | string | 否 | 表示待启动的Ability所属的模块(module)。同一应用的不同hap的组件可能重名,仅通过BundleName和AbilityName无法区分时,可以通过设置moduleName加以区分,以匹配到指定的Ability。 | | +| moduleName9+ | 只读 | string | 否 | 表示待启动的Ability所属的模块(module)。同一应用的不同hap的组件可能重名,仅通过BundleName和AbilityName无法区分时,可以通过设置moduleName加以区分,以匹配到指定的Ability。 | | diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-ability.md b/zh-cn/application-dev/reference/apis/js-apis-application-ability.md index 306be5858bbcc592b89484bb149187a67d8376cb..00987cd540405376a4dde2ec55483e537927a811 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-ability.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-ability.md @@ -259,6 +259,31 @@ onConfigurationUpdated(config: Configuration): void; } ``` +## Ability.dump + +dump(params: Array\): Array\; + +指示from命令的参数。 + +**系统能力**:SystemCapability.Ability.AbilityRuntime.AbilityCore + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | params | Array\ | 是 | 指示from命令的参数。| + +**示例:** + + ```js + class myAbility extends Ability { + dump(params) { + console.log('dump, params:' + JSON.stringify(params)); + } + } + ``` + + ## Caller diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-abilityDelegator.md b/zh-cn/application-dev/reference/apis/js-apis-application-abilityDelegator.md index 1900632c2e0738d4b7e9fde059aea897c5d5f80d..cfaa22a541b3c3500bc43f6b5d06ffb7ede7bf0a 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-abilityDelegator.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-abilityDelegator.md @@ -7,7 +7,7 @@ ## 导入模块 ```js -import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import AbilityDelegator from '@ohos.application.abilityDelegator' ``` @@ -747,7 +747,7 @@ abilityDelegator.executeShellCommand(cmd, timeout, (err : any, data : any) => { ### executeShellCommand -executeShellCommand(cmd: string, timeoutSecs: number): Promise\ +executeShellCommand(cmd: string, timeoutSecs?: number): Promise\ 指定超时时间,并执行指定的shell命令(promise形式) diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-abilityDelegatorArgs.md b/zh-cn/application-dev/reference/apis/js-apis-application-abilityDelegatorArgs.md index 2fb204540b33ab4c510a21145a89474c02145eaa..b1b16092e204fce1382d373dfe07a89d9b88efb5 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-abilityDelegatorArgs.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-abilityDelegatorArgs.md @@ -7,7 +7,7 @@ ## 导入模块 ```js -import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import AbilityDelegatorArgs from '@ohos.application.abilityDelegatorArgs' ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-abilityLifecycleCallback.md b/zh-cn/application-dev/reference/apis/js-apis-application-abilityLifecycleCallback.md index bd4ad4df68876f68e384e639fccf9b912c21d52c..007c4af80328d3821118803610b551c97fc424f2 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-abilityLifecycleCallback.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-abilityLifecycleCallback.md @@ -6,6 +6,12 @@ 应用上下文ApplicationContext的生命周期监听方法的回调类,里面提供了onAbilityCreate、onAbilityWindowStageCreate、onAbilityWindowStageDestroy等方法。 +## 导入模块 + +```js +import AbilityLifecycleCallback from "@ohos.application.abilityLifecycleCallback"; +``` + ## AbilityLifecycleCallback.onAbilityCreate diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-context.md b/zh-cn/application-dev/reference/apis/js-apis-application-context.md index 5aec0d2417ee41692b6b249f17bcdca5c4369412..98fabaea000ed1a0d8fcef18651beb1bf4d0d8cf 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-context.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-context.md @@ -6,7 +6,11 @@ 提供开发者运行代码的上下文环境,包括应用信息、ResourceManager等信息。 +## 导入模块 +```js +import Context from "@ohos.application.context"; +``` ## 使用说明 diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-missionInfo.md b/zh-cn/application-dev/reference/apis/js-apis-application-missionInfo.md new file mode 100644 index 0000000000000000000000000000000000000000..11e918744ddf82d4000c1d0eddf0e617ad663385 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-application-missionInfo.md @@ -0,0 +1,28 @@ +# MissionInfo + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + +## 导入模块 + +```js +import MissionInfo from '@ohos.application.missionInfo' +``` + + +## MissionInfo + +表示Ability对应任务信息的枚举。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityBase + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| -------- | -------- | -------- | -------- | -------- | +| missionId | number | 是 | 是 | 表示任务ID。| +| runningState | number | 是 | 是 | 表示运行状态。 | +| lockedState | boolean | 是 | 是 | 表示锁定状态。 | +| timestamp | string | 是 | 是 | 表示任务的最近创建或更新时间。 | +| want | [Want](js-apis-application-Want.md) | 是 | 是 | 表示任务的Want信息。 | +| label | string | 是 | 是 | 表示任务的标签。 | +| iconPath | string | 是 | 是 | 表示任务的图标路径。 | +| continuable | boolean | 是 | 是 | 表示任务是否可以继续。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-shellCmdResult.md b/zh-cn/application-dev/reference/apis/js-apis-application-shellCmdResult.md index 7d6fc93ecf7416cfc0ae381f7276b2e70d08d776..f5b4604103f502c2578e66ec0a3c8f246f39bc6a 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-shellCmdResult.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-shellCmdResult.md @@ -7,7 +7,7 @@ ## 导入模块 ```js -import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import ShellCmdResult from '@ohos.application.shellCmdResult' ``` 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 d0735c83249f4282d1060fd957354c75de4e39e6..c5f31e58aad9e6e7fc8a63dea9d94f732a64c801 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-appmanager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-appmanager.md @@ -160,7 +160,7 @@ getAppMemorySize(callback: AsyncCallback\): void; ``` ## appManager.getProcessRunningInfos8+ -getProcessRunningInfos(): Promise>; +getProcessRunningInfos(): Promise>; 获取有关运行进程的信息。 @@ -184,7 +184,7 @@ getProcessRunningInfos(): Promise>; ## appManager.getProcessRunningInfos8+ -getProcessRunningInfos(callback: AsyncCallback>): void; +getProcessRunningInfos(callback: AsyncCallback>): void; 获取有关运行进程的信息。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-call.md b/zh-cn/application-dev/reference/apis/js-apis-call.md index 907d13afcebed25b17aacc68208a3e861735219a..c7afa64a1279f109c0ae1285b52737f13575f677 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-call.md +++ b/zh-cn/application-dev/reference/apis/js-apis-call.md @@ -2,7 +2,7 @@ call模块提供呼叫管理功能,包括拨打电话、跳转到拨号界面、获取通话状态、格式化电话号码等。 -如需订阅通话状态请使用[`observer.on('callStateChange')`](../reference/apis/js-apis-observer.md#observeroncallstatechange)。 +如需订阅通话状态请使用[`observer.on('callStateChange')`](js-apis-observer.md#observeroncallstatechange)。 >**说明:** > diff --git a/zh-cn/application-dev/reference/apis/js-apis-cardEmulation.md b/zh-cn/application-dev/reference/apis/js-apis-cardEmulation.md index 8111e53fe8502ffc811a942441b19e465b376d9b..2a88d01e5b99f51ca9f95e12dba45c36b61b7c58 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-cardEmulation.md +++ b/zh-cn/application-dev/reference/apis/js-apis-cardEmulation.md @@ -21,14 +21,15 @@ isSupported(feature: number): boolean **系统能力**:SystemCapability.Communication.NFC -- 返回值: +**返回值:** + | **类型** | **说明** | | -------- | -------- | | boolean | true:支持该类型卡模拟, false:不支持该类型卡模拟。 | ## HceService -管理HCE卡模拟。在调用HceService的接口前,需要先通过getHceService创建实例。 +管理HCE卡模拟。在调用HceService的接口前,需要先通过new cardEmulation.HceService()创建实例。 ### startHCE @@ -91,7 +92,7 @@ sendResponse(responseApdu: number[]): void; **示例:** -``` +```js var hceService = new cardEmulation.HceService(); hceService.startHCE([ "F0010203040506", "A0000000041010" diff --git a/zh-cn/application-dev/reference/apis/js-apis-dataAbilityHelper.md b/zh-cn/application-dev/reference/apis/js-apis-dataAbilityHelper.md index ff076ae0813454d0dfbf033547ecce11ae1fb896..858884076af1a7699c2fe9c3b841eeaa15084157 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-dataAbilityHelper.md +++ b/zh-cn/application-dev/reference/apis/js-apis-dataAbilityHelper.md @@ -5,6 +5,13 @@ ## 导入模块 +```js +import dataAbilityHelper from "@ohos.ability.dataAbilityHelper"; +``` + +## 使用说明 + +使用前根据具体情况引入如下模块 ``` import featureAbility from '@ohos.ability.featureAbility' import ohos_data_ability from '@ohos.data.dataability' 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 9d0b459d822d92c066991609133b1def27bd8f55..1fd8f739e8c7d01855a3d1002284c19ca753305d 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 @@ -3,6 +3,7 @@ 分布式数据管理为应用程序提供不同设备间数据库的分布式协同能力。通过调用分布式数据各个接口,应用程序可将数据保存到分布式数据库中,并可对分布式数据库中的数据进行增/删/改/查等各项操作。 >**说明:** +> >本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 @@ -19,7 +20,7 @@ createKVManager(config: KVManagerConfig, callback: AsyncCallback<KVManager> 创建一个KVManager对象实例,用于管理数据库对象,并通过callback方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -58,7 +59,7 @@ createKVManager(config: KVManagerConfig): Promise<KVManager> 创建一个KVManager对象实例,用于管理数据库对象,并通过Promise方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -139,7 +140,7 @@ getKVStore<T extends KVStore>(storeId: string, options: Options, callback: 通过指定Options和storeId,创建并获取KVStore数据库,并通过callback方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -183,7 +184,7 @@ getKVStore<T extends KVStore>(storeId: string, options: Options): Promise& 通过指定Options和storeId,创建并获取KVStore数据库,并通过Promise方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -230,7 +231,7 @@ closeKVStore(appId: string, storeId: string, kvStore: KVStore, callback: AsyncCa 通过storeId的值关闭指定的KVStore数据库,并通过callback方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -276,7 +277,7 @@ closeKVStore(appId: string, storeId: string, kvStore: KVStore): Promise<void& 通过storeId的值关闭指定的KVStore数据库,并通过Promise方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -330,7 +331,7 @@ deleteKVStore(appId: string, storeId: string, callback: AsyncCallback<void> 通过storeId的值删除指定的KVStore数据库,并通过callback方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -373,7 +374,7 @@ deleteKVStore(appId: string, storeId: string): Promise<void> 通过storeId的值删除指定的KVStore数据库,并通过Promise方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -427,14 +428,14 @@ getAllKVStoreId(appId: string, callback: AsyncCallback<string[]>): void 获取所有通过[getKVStore](#getkvstore)方法创建的且没有调用[deleteKVStore](#deletekvstore8)方法删除的KVStore数据库的storeId,并通过callback方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | appId | string | 是 | 所调用数据库方的包名。 | -| callback | AsyncCallback<void> | 是 |回调函数,返回所有创建的 KvStore 数据库的 storeId。 | +| callback | AsyncCallback<void> | 是 |回调函数,返回所有创建的KvStore数据库的storeId。 | **示例:** @@ -457,7 +458,7 @@ getAllKVStoreId(appId: string): Promise<string[]> 获取所有通过[getKVStore](#getkvstore)方法创建的且没有调用[deleteKVStore](#deletekvstore8)方法删除的KVStore数据库的storeId,并通过Promise方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -470,7 +471,7 @@ getAllKVStoreId(appId: string): Promise<string[]> | 类型 | 说明 | | ------------- | -------------- | -| Promise<string[]>| Promise实例,返回所有创建的 KvStore 数据库的 storeId。 | +| Promise<string[]>| Promise实例,返回所有创建的KvStore数据库的storeId。 | **示例:** @@ -593,11 +594,11 @@ try { | 名称 | 默认值 | 说明 | | --- | ---- | ----------------------- | | NO_LEVEL | 0 | 表示数据库不设置安全级别。 | -| S0 | 1 | 表示数据库的安全级别为公共级别安全。 | -| S1 | 2 | 表示数据库的安全级别为低级别安全,当数据泄露时会产生较低影响。 | -| S2 | 3 | 表示数据库的安全级别为中级别安全,当数据泄露时会产生较大影响。 | -| S3 | 5 | 表示数据库的安全级别为高级别安全,当数据泄露时会产生重大影响。 | -| S4 | 6 | 表示数据库的安全级别为关键级别安全,当数据泄露时会产生严重影响。 | +| S0 | 1 | 表示数据库的安全级别为公共级别。 | +| S1 | 2 | 表示数据库的安全级别为低级别,当数据泄露时会产生较低影响。 | +| S2 | 3 | 表示数据库的安全级别为中级别,当数据泄露时会产生较大影响。 | +| S3 | 5 | 表示数据库的安全级别为高级别,当数据泄露时会产生重大影响。 | +| S4 | 6 | 表示数据库的安全级别为关键级别,当数据泄露时会产生严重影响。 | ## Constants @@ -610,14 +611,14 @@ KVStore常量。 | --- | ---- | ----------------------- | | MAX_KEY_LENGTH | 1024 | 数据库中Key允许最大长度,单位字节。 | | MAX_VALUE_LENGTH | 4194303 | 数据库中Value允许的最大长度,单位字节。 | -| MAX_KEY_LENGTH_DEVICE | 896 | 最大设备坐标密钥长度。 | +| MAX_KEY_LENGTH_DEVICE | 896 | 最大设备坐标密钥长度,单位字节。 | | MAX_STORE_ID_LENGTH | 128 | 数据库标识符允许的最大长度,单位字节。 | -| MAX_QUERY_LENGTH | 512000 | 最大查询长度。 | -| MAX_BATCH_SIZE | 128 | 最大批处理操作大小。 | +| MAX_QUERY_LENGTH | 512000 | 最大查询长度,单位字节。 | +| MAX_BATCH_SIZE | 128 | 最大批处理操作数量。 | ## Schema8+ ## -表示数据库模式,可以在创建或打开数据库时创建 Schema 对象并将它们放入 Options 中。 +表示数据库模式,可以在创建或打开数据库时创建Schema对象并将它们放入[Options](#options)中。 **系统能力:** 以下各项对应的系统能力均为 SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 @@ -646,7 +647,7 @@ constructor() | --- | ---- | ----------------------- | | nullable8+ | boolean | 表示数据库字段是否可以为空。 | | default8+ | string | 表示Fieldnode的默认值。 | -| type8+ | number | 表示值。 | +| type8+ | number | 表示指定节点对应数据类型的值。 | ### constructor8+ ### @@ -666,7 +667,7 @@ constructor(name: string) appendChild(child: FieldNode): boolean -向这个 FieldNode 添加一个子节点。 +在当前 FieldNode 中添加一个子节点。 **系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 @@ -680,7 +681,7 @@ appendChild(child: FieldNode): boolean | 类型 | 说明 | | ------------- | -------------- | -| boolean |如果子节点成功添加到这个FieldNode,则返回 true;否则返回 false。 | +| boolean |如果子节点成功添加到FieldNode,则返回 true,否则返回false。 | **示例:** @@ -707,7 +708,7 @@ try { ## KvStoreResultSet8+ ## -提供获取KVStore数据库结果集的方法,提供查询和移动数据读取位置的方法,在调用KvStoreResultSet的方法前,需要先通过KVStore 构建一个KVStore 实例。 +提供获取KVStore数据库结果集的方法,提供查询和移动数据读取位置的方法,在调用KvStoreResultSet的方法前,需要先通过KVStore构建一个KVStore实例。 ### getCount8+ ### @@ -716,7 +717,7 @@ getCount(): number 获取结果集中的行数。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **返回值:** @@ -731,15 +732,15 @@ let kvStore; try { let resultSet; kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet success'); + console.log('getResultSet succeed.'); resultSet = result; }).catch((err) => { - console.log('getResultSet fail ' + err); + console.log('getResultSet failed:ed: ' + err); }); const count = resultSet.getCount(); - console.log("GetCount " + count); + console.log("getCount succeed:" + count); } catch (e) { - console.log("GetCount fail " + e); + console.log("getCount failed: " + e); } ``` @@ -749,7 +750,7 @@ getPosition(): number 获取结果集中当前的读取位置。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **返回值:** @@ -764,15 +765,15 @@ let kvStore; try { let resultSet; kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet success'); + console.log('getResultSet succeeed.'); resultSet = result; }).catch((err) => { - console.log('getResultSet fail ' + err); + console.log('getResultSet failed:ed: ' + err); }); const position = resultSet.getPosition(); - console.log("getPosition " + position); + console.log("getPosition succeed:" + position); } catch (e) { - console.log("GetPosition fail " + e); + console.log("getPosition failed: " + e); } ``` @@ -783,13 +784,13 @@ moveToFirst(): boolean 将读取位置移动到第一行。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **返回值:** | 类型 | 说明 | | ------ | -------------- | -| boolean |如果操作成功则返回true,否则返回 false。 | +| boolean |如果操作成功则返回true,否则返回false。 | **示例:** @@ -798,15 +799,15 @@ let kvStore; try { let resultSet; kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet success'); + console.log('getResultSet succeed.'); resultSet = result; }).catch((err) => { - console.log('getResultSet fail ' + err); + console.log('getResultSet failed: ' + err); }); - const moved = resultSet.moveToFirst(); - console.log("moveToFirst " + moved); + const moved1 = resultSet.moveToFirst(); + console.log("moveToFirst succeed: " + moved1); } catch (e) { - console.log("MoveToFirst fail " + e); + console.log("moveToFirst failed " + e); } ``` @@ -817,13 +818,13 @@ moveToLast(): boolean 将读取位置移动到最后一行。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **返回值:** | 类型 | 说明 | | ------ | -------------- | -| boolean |如果操作成功则返回true,否则返回 false。 | +| boolean |如果操作成功则返回true,否则返回false。 | **示例:** @@ -832,15 +833,15 @@ let kvStore; try { let resultSet; kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet success'); + console.log('getResultSet succeed.'); resultSet = result; }).catch((err) => { - console.log('getResultSet fail ' + err); + console.log('getResultSet failed: ' + err); }); - const moved = resultSet.moveToLast(); - console.log("moveToLast " + moved); + const moved2 = resultSet.moveToLast(); + console.log("moveToLast succeed:" + moved2); } catch (e) { - console.log("moveToLast fail " + e); + console.log("moveToLast failed: " + e); } ``` @@ -851,13 +852,13 @@ moveToNext(): boolean 将读取位置移动到下一行。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **返回值:** | 类型 | 说明 | | ------ | -------------- | -| boolean |如果操作成功则返回true,否则返回 false。 | +| boolean |如果操作成功则返回true,否则返回false。 | **示例:** @@ -866,15 +867,15 @@ let kvStore; try { let resultSet; kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet success'); + console.log('getResultSet succeed.'); resultSet = result; }).catch((err) => { - console.log('getResultSet fail ' + err); + console.log('getResultSet failed: ' + err); }); - const moved = resultSet.moveToNext(); - console.log("moveToNext " + moved); + const moved3 = resultSet.moveToNext(); + console.log("moveToNext succeed: " + moved3); } catch (e) { - console.log("moveToNext fail " + e); + console.log("moveToNext failed: " + e); } ``` @@ -885,13 +886,13 @@ moveToPrevious(): boolean 将读取位置移动到上一行。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **返回值:** | 类型 | 说明 | | ------ | -------------- | -| boolean |如果操作成功则返回true,否则返回 false。 | +| boolean |如果操作成功则返回true,否则返回false。 | **示例:** @@ -900,15 +901,15 @@ let kvStore; try { let resultSet; kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet success'); + console.log('getResultSet succeed.'); resultSet = result; }).catch((err) => { - console.log('getResultSet fail ' + err); + console.log('getResultSet failed: ' + err); }); - const moved = resultSet.moveToPrevious(); - console.log("moveToPrevious " + moved); + const moved4 = resultSet.moveToPrevious(); + console.log("moveToPrevious succeed:" + moved4); } catch (e) { - console.log("moveToPrevious fail " + e); + console.log("moveToPrevious failed: " + e); } ``` @@ -919,7 +920,7 @@ move(offset: number): boolean 将读取位置移动到当前位置的相对偏移量。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -931,7 +932,7 @@ move(offset: number): boolean | 类型 | 说明 | | ------ | -------------- | -| boolean |如果操作成功则返回true,否则返回 false。 | +| boolean |如果操作成功则返回true,否则返回false。 | **示例:** @@ -940,15 +941,15 @@ let kvStore; try { let resultSet; kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet success'); + console.log('getResultSet succeed.'); resultSet = result; }).catch((err) => { - console.log('getResultSet fail ' + err); + console.log('getResultSet failed: ' + err); }); - const moved = resultSet.move(); - console.log("move " + moved); + const moved5 = resultSet.move(); + console.log("move succeed:" + moved5); } catch (e) { - console.log("move fail " + e); + console.log("move failed: " + e); } ``` @@ -959,7 +960,7 @@ moveToPosition(position: number): boolean 将读取位置从 0 移动到绝对位置。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -971,7 +972,7 @@ moveToPosition(position: number): boolean | 类型 | 说明 | | ------ | -------------- | -| boolean |如果操作成功则返回true,否则返回 false。 | +| boolean |如果操作成功则返回true,否则返回false。 | **示例:** @@ -980,15 +981,15 @@ let kvStore; try { let resultSet; kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet success'); + console.log('getResultSet succeed.'); resultSet = result; }).catch((err) => { - console.log('getResultSet fail ' + err); + console.log('getResultSet failed: ' + err); }); - const moved = resultSet.moveToPosition(); - console.log("moveToPosition " + moved); + const moved6 = resultSet.moveToPosition(); + console.log("moveToPosition succeed: " + moved6); } catch (e) { - console.log("moveToPosition fail " + e); + console.log("moveToPosition failed: " + e); } ``` @@ -999,13 +1000,13 @@ isFirst(): boolean 检查读取位置是否为第一行。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **返回值:** | 类型 | 说明 | | ------ | -------------- | -| boolean |如果读取位置是第一行,则返回 true;否则返回 false。 | +| boolean |如果操作成功则返回true,否则返回false。 | **示例:** @@ -1014,15 +1015,15 @@ let kvStore; try { let resultSet; kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet success'); + console.log('getResultSet succeed.'); resultSet = result; }).catch((err) => { - console.log('getResultSet fail ' + err); + console.log('getResultSet failed: ' + err); }); - const moved = resultSet.isFirst(); - console.log("isFirst " + moved); + const isfirst = resultSet.isFirst(); + console.log("Check isFirst succeed:" + isfirst); } catch (e) { - console.log("isFirst fail " + e); + console.log("Check isFirst failed: " + e); } ``` @@ -1033,13 +1034,13 @@ isLast(): boolean 检查读取位置是否为最后一行。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **返回值:** | 类型 | 说明 | | ------ | -------------- | -| boolean |如果读取位置是最后一行,则返回 true;否则返回 false。 | +| boolean |如果读取位置是最后一行,则返回 true,否则返回false。 | **示例:** @@ -1048,15 +1049,15 @@ let kvStore; try { let resultSet; kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet success'); + console.log('getResultSet succeed.'); resultSet = result; }).catch((err) => { - console.log('getResultSet fail ' + err); + console.log('getResultSet failed: ' + err); }); - const moved = resultSet.isLast(); - console.log("isLast " + moved); + const islast = resultSet.isLast(); + console.log("Check isLast succeed: " + islast); } catch (e) { - console.log("isLast fail " + e); + console.log("Check isLast failed: " + e); } ``` @@ -1066,13 +1067,13 @@ isBeforeFirst(): boolean 检查读取位置是否在第一行之前。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **返回值:** | 类型 | 说明 | | ------ | -------------- | -| boolean |如果读取位置在第一行之前,则返回 true;否则返回 false。 | +| boolean |如果读取位置在第一行之前,则返回 true,否则返回false。 | **示例:** @@ -1081,15 +1082,15 @@ let kvStore; try { let resultSet; kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet success'); + console.log('getResultSet succeed.'); resultSet = result; }).catch((err) => { - console.log('getResultSet fail ' + err); + console.log('getResultSet failed: ' + err); }); - const moved = resultSet.isBeforeFirst(); - console.log("isBeforeFirst " + moved); + const isbeforefirst = resultSet.isBeforeFirst(); + console.log("Check isBeforeFirst succeed: " + isbeforefirst); } catch (e) { - console.log("isBeforeFirst fail " + e); + console.log("Check isBeforeFirst failed: " + e); } ``` @@ -1100,13 +1101,13 @@ isAfterLast(): boolean 检查读取位置是否在最后一行之后。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **返回值:** | 类型 | 说明 | | ------ | -------------- | -| boolean |如果读取位置在最后一行之后,则返回 true;否则返回 false。 | +| boolean |如果读取位置在最后一行之后,则返回 true,否则返回false。 | **示例:** @@ -1115,15 +1116,15 @@ let kvStore; try { let resultSet; kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet success'); + console.log('getResultSet succeed.'); resultSet = result; }).catch((err) => { - console.log('getResultSet fail ' + err); + console.log('getResultSet failed: ' + err); }); - const moved = resultSet.isAfterLast(); - console.log("isAfterLast " + moved); + const isafterlast = resultSet.isAfterLast(); + console.log("Check isAfterLast succeed:" + isafterlast); } catch (e) { - console.log("isAfterLast fail " + e); + console.log("Check isAfterLast failed: " + e); } ``` @@ -1134,7 +1135,7 @@ getEntry(): Entry 获取键值对。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **返回值:** @@ -1149,16 +1150,15 @@ let kvStore; try { let resultSet; kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet success'); + console.log('getResultSet succeed.'); resultSet = result; }).catch((err) => { - console.log('getResultSet fail ' + err); + console.log('getResultSet failed: ' + err); }); - const moved = resultSet.moveToNext(); const entry = resultSet.getEntry(); - console.log("getEntry " + JSON.stringify(entry)); + console.log("getEntry succeed:" + JSON.stringify(entry)); } catch (e) { - console.log("getEntry fail " + e); + console.log("getEntry failed: " + e); } ``` @@ -1167,7 +1167,7 @@ try { 使用谓词表示数据库查询,提供创建Query实例、查询数据库中的数据和添加谓词的方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core ### constructor8+ ### @@ -1175,7 +1175,7 @@ constructor() 用于创建Schema实例的构造函数。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core ### reset8+ ### @@ -1184,14 +1184,14 @@ reset(): Query 公共查询重置。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **返回值:** | 类型 | 说明 | | ------ | ------- | -| [Query](#query8) |返回重置的 Query 对象。| +| [Query](#query8) |返回重置的Query对象。| **示例:** @@ -1215,20 +1215,20 @@ equalTo(field: string, value: number|string|boolean): Query 构造一个Query对象来查询具有指定字段的条目,其值等于指定的值。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | -| fieId | string | 是 |表示指定字段,不能包含' ^ '。 | +| fieId | string | 是 |表示指定字段,且不能包含' ^ '。 | | value | number\|string\|boolean | 是 | 表示指定的值。| **返回值:** | 类型 | 说明 | | ------ | ------- | -| [Query](#query8) |返回重置的 Query 对象。| +| [Query](#query8) |返回重置的Query对象。| **示例:** @@ -1250,20 +1250,20 @@ notEqualTo(field: string, value: number|string|boolean): Query 构造一个Query对象以查询具有指定字段且值不等于指定值的条目。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | -| fieId | string | 是 |表示指定字段,必须以$开头, 并且不能包含' ^ '。 | +| fieId | string | 是 |表示指定字段,且不能包含' ^ '。 | | value | number\|string\|boolean | 是 | 表示指定的值。| **返回值:** | 类型 | 说明 | | ------ | ------- | -| [Query](#query8) |返回重置的 Query 对象。| +| [Query](#query8) |返回重置的Query对象。| **示例:** @@ -1285,13 +1285,13 @@ greaterThan(field: string, value: number|string|boolean): Query 构造一个Query对象以查询具有大于指定值的指定字段的条目。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | -| fieId | string | 是 |表示指定字段,必须以$开头, 并且不能包含' ^ '。 | +| fieId | string | 是 |表示指定字段,且不能包含' ^ '。 | | value | number\|string\|boolean | 是 | 表示指定的值。| **返回值:** @@ -1320,13 +1320,13 @@ lessThan(field: string, value: number|string): Query 构造一个Query对象以查询具有小于指定值的指定字段的条目。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | -| fieId | string | 是 |表示指定字段,必须以$开头, 并且不能包含' ^ '。 | +| fieId | string | 是 |表示指定字段,且不能包含' ^ '。 | | value | number\|string\|boolean | 是 | 表示指定的值。| **返回值:** @@ -1355,13 +1355,13 @@ greaterThanOrEqualTo(field: string, value: number|string): Query 构造一个Query对象以查询具有指定字段且值大于或等于指定值的条目。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | -| fieId | string | 是 |表示指定字段,必须以$开头, 并且不能包含' ^ '。 | +| fieId | string | 是 |表示指定字段,且不能包含' ^ '。 | | value | number\|string\|boolean | 是 | 表示指定的值。| **返回值:** @@ -1390,13 +1390,13 @@ lessThanOrEqualTo(field: string, value: number|string): Query 构造一个Query对象以查询具有指定字段且值小于或等于指定值的条目。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | -| fieId | string | 是 |表示指定字段,必须以$开头, 并且不能包含' ^ '。 | +| fieId | string | 是 |表示指定字段,且不能包含' ^ '。 | | value | number\|string\|boolean | 是 | 表示指定的值。| **返回值:** @@ -1426,13 +1426,13 @@ isNull(field: string): Query 构造一个Query对象以查询具有值为null的指定字段的条目。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | -| fieId | string | 是 |表示指定字段,必须以$开头, 并且不能包含' ^ '。 | +| fieId | string | 是 |表示指定字段,且不能包含' ^ '。 | **返回值:** @@ -1461,13 +1461,13 @@ inNumber(field: string, valueList: number[]): Query 构造一个Query对象以查询具有指定字段的条目,其值在指定的值列表中。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | -| fieId | string | 是 |表示指定字段,必须以$开头, 并且不能包含' ^ '。 | +| fieId | string | 是 |表示指定字段,且不能包含' ^ '。 | | valueList | number[] | 是 | 表示指定的值列表。| **返回值:** @@ -1496,13 +1496,13 @@ inString(field: string, valueList: string[]): Query 构造一个Query对象以查询具有指定字段的条目,其值在指定的字符串值列表中。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | -| fieId | string | 是 |表示指定字段,必须以$开头, 并且不能包含' ^ '。 | +| fieId | string | 是 |表示指定字段,且不能包含' ^ '。 | | valueList | string[] | 是 | 表示指定的字符串值列表。| **返回值:** @@ -1531,13 +1531,13 @@ notInNumber(field: string, valueList: number[]): Query 构造一个Query对象以查询具有指定字段的条目,该字段的值不在指定的值列表中。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | -| fieId | string | 是 |表示指定字段,必须以$开头, 并且不能包含' ^ '。 | +| fieId | string | 是 |表示指定字段,且不能包含' ^ '。 | | valueList | number[] | 是 | 表示指定的值列表。| **返回值:** @@ -1566,13 +1566,13 @@ notInString(field: string, valueList: string[]): Query 构造一个Query对象以查询具有指定字段且值不在指定字符串值列表中的条目。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | -| fieId | string | 是 |表示指定字段,必须以$开头, 并且不能包含' ^ '。 | +| fieId | string | 是 |表示指定字段,且不能包含' ^ '。 | | valueList | string[] | 是 | 表示指定的字符串值列表。| **返回值:** @@ -1601,14 +1601,14 @@ like(field: string, value: string): Query 构造一个Query对象以查询具有与指定字符串值相似的指定字段的条目。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | -| fieId | string | 是 |表示指定字段,必须以$开头, 并且不能包含' ^ '。 | -| valueList | string | 是 | 表示指定的字符串值。| +| fieId | string | 是 |表示指定字段,且不能包含' ^ '。 | +| value | string | 是 | 表示指定的字符串值。| **返回值:** @@ -1636,14 +1636,14 @@ unlike(field: string, value: string): Query 构造一个Query对象以查询具有与指定字符串值不相似的指定字段的条目。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | -| fieId | string | 是 |表示指定字段,必须以$开头, 并且不能包含' ^ '。 | -| valueList | string | 是 | 表示指定的字符串值。| +| fieId | string | 是 |表示指定字段,且不能包含' ^ '。 | +| value | string | 是 | 表示指定的字符串值。| **返回值:** @@ -1671,7 +1671,7 @@ and(): Query 构造一个带有与条件的查询对象。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **返回值:** @@ -1701,7 +1701,7 @@ or(): Query 构造一个带有或条件的Query对象。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **返回值:** @@ -1731,13 +1731,13 @@ orderByAsc(field: string): Query 构造一个Query对象,将查询结果按升序排序。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | -| fieId | string | 是 |表示指定字段,必须以$开头, 并且不能包含' ^ '。 | +| fieId | string | 是 |表示指定字段,且不能包含' ^ '。 | **返回值:** @@ -1766,13 +1766,13 @@ orderByDesc(field: string): Query 构造一个Query对象,将查询结果按降序排序。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | -| fieId | string | 是 |表示指定字段,必须以$开头, 并且不能包含' ^ '。 | +| fieId | string | 是 |表示指定字段,且不能包含' ^ '。 | **返回值:** @@ -1801,7 +1801,7 @@ limit(total: number, offset: number): Query 构造一个Query对象来指定结果的数量和开始位置。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -1837,7 +1837,7 @@ isNotNull(field: string): Query 使用不为空的指定字段创建查询条件。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -1871,7 +1871,7 @@ beginGroup(): Query 创建一个带有左括号的查询条件组。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **返回值:** @@ -1901,7 +1901,7 @@ endGroup(): Query 创建一个带有右括号的查询条件组。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **返回值:** @@ -1931,7 +1931,7 @@ prefixKey(prefix: string): Query 创建具有指定键前缀的查询条件。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -1966,7 +1966,7 @@ setSuggestIndex(index: string): Query 设置一个指定的索引,将优先用于查询。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -2001,13 +2001,13 @@ deviceId(deviceId:string):Query 添加设备ID作为key的前缀。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | -| deviceId | string | 是 |指示查询的设备 ID。 | +| deviceId | string | 是 |指示查询的设备ID。 | **返回值:** @@ -2035,13 +2035,13 @@ getSqlLike():string 获取指定Query对象的查询语句。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **返回值:** | 类型 | 说明 | | ------ | ------- | -| [Query](#query8) |返回查询对象。| +| string |返回一个字段列中包含对应子串的结果。| **示例:** @@ -2058,9 +2058,7 @@ try { ## KVStore -KVStore数据库实例,提供增加数据、删除数据和订阅数据变更、订阅同步完成的方法。在调用KVStore的方法前,需要先通过getKVStore构建一个KVStore实例。 - -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +KVStore数据库实例,提供增加数据、删除数据和订阅数据变更、订阅数据同步完成的方法。在调用KVStore的方法前,需要先通过[getKVStore](#getkvstore)构建一个KVStore实例。 ### put @@ -2068,7 +2066,7 @@ put(key: string, value: Uint8Array | string | number | boolean, callback: AsyncC 添加指定类型键值对到数据库,并通过callback方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -2104,7 +2102,7 @@ put(key: string, value: Uint8Array | string | number | boolean): Promise<void 添加指定类型键值对到数据库,并通过Promise方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -2143,7 +2141,7 @@ delete(key: string, callback: AsyncCallback<void>): void 从数据库中删除指定键值的数据,并通过callback方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -2185,7 +2183,7 @@ delete(key: string): Promise<void> 从数据库中删除指定键值的数据,并通过Promise方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -2228,7 +2226,7 @@ on(event: 'dataChange', type: SubscribeType, observer: Callback<ChangeNotific 订阅指定类型的数据变更通知,此方法为同步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -2254,7 +2252,7 @@ on(event: 'syncComplete', syncCallback: Callback<Array<[string, number]> 订阅同步完成事件回调通知,此方法为同步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -2278,7 +2276,7 @@ off(event:'dataChange', observer?: Callback<ChangeNotification>): void 取消订阅数据变更通知,此方法为同步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -2306,7 +2304,7 @@ putBatch(entries: Entry[], callback: AsyncCallback<void>): void 批量插入键值对到KVStore数据库中,并通过callback方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -2353,7 +2351,7 @@ putBatch(entries: Entry[]): Promise<void> 批量插入键值对到KVStore数据库中,并通过Promise方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -2408,7 +2406,7 @@ deleteBatch(keys: string[], callback: AsyncCallback<void>): void 批量删除KVStore数据库中的键值对,并通过callback方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -2455,7 +2453,7 @@ deleteBatch(keys: string[]): Promise<void> 批量删除KVStore数据库中的键值对,并通过Promise方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -2511,7 +2509,7 @@ startTransaction(callback: AsyncCallback<void>): void 启动KVStore数据库中的事务,并通过callback方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -2563,7 +2561,7 @@ startTransaction(): Promise<void> 启动KVStore数据库中的事务,并通过Promise方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **返回值:** @@ -2598,7 +2596,7 @@ commit(callback: AsyncCallback<void>): void 提交KVStore数据库中的事务,并通过callback方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -2630,7 +2628,7 @@ commit(): Promise<void> 提交KVStore数据库中的事务,并通过Promise方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **返回值:** @@ -2660,7 +2658,7 @@ rollback(callback: AsyncCallback<void>): void 在KVStore数据库中回滚事务,并通过callback方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -2692,7 +2690,7 @@ rollback(): Promise<void> 在KVStore数据库中回滚事务,并通过Promise方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **返回值:** @@ -2722,13 +2720,13 @@ enableSync(enabled: boolean, callback: AsyncCallback<void>): void 设定是否开启同步,并通过callback方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | -| enabled |boolean | 是 |指定是否开启同步,ture表示开启同步,false表示不启用同步。 | +| enabled |boolean | 是 |设定是否开启同步,true表示开启同步,false表示不启用同步。 | | callback |AsyncCallback<void> | 是 |回调函数。 | **示例:** @@ -2755,13 +2753,13 @@ enableSync(enabled: boolean): Promise<void> 设定是否开启同步,并通过Promise方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | -| enabled |boolean | 是 |指定是否开启同步,ture表示开启同步,false表示不启用同步。 | +| enabled |boolean | 是 |设定是否开启同步,true表示开启同步,false表示不启用同步。 | **返回值:** @@ -2791,7 +2789,7 @@ setSyncRange(localLabels: string[], remoteSupportLabels: string[], callback: Asy 设置同步范围标签,并通过callback方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -2823,7 +2821,7 @@ setSyncRange(localLabels: string[], remoteSupportLabels: string[]): Promise<v 设置同步范围标签,并通过Promise方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -2896,14 +2894,14 @@ try { ## Value -存储在数据库中的对象。 +存储在数据库中的值对象。 **系统能力:** 以下各项对应的系统能力均为 SystemCapability.DistributedDataManager.KVStore.Core。 | 名称 | 参数类型 |可读 |可写 | 说明 | | ----- | ------- | -----| ------|------------------------ | | type | [ValueType](#value) | 是 | 是 |值类型。 | -| value | Uint8Array \| string \| number \| boolean| 是 | 是 |值对象。 | +| value | Uint8Array \| string \| number \| boolean| 是 | 是 |值。 | ## ValueType @@ -2924,9 +2922,7 @@ try { ## SingleKVStore -单版本分布式数据库,继承自KVStore,提供查询数据和同步数据的方法。在调用 SingleKVStore 的方法前,需要先通过 [getKVStore](#getkvstore) 构建一个 SingleKVStore 实例。 - -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +单版本分布式数据库,继承自KVStore,提供查询数据和同步数据的方法。在调用SingleKVStore的方法前,需要先通过 [getKVStore](#getkvstore) 构建一个SingleKVStore实例。 ### get @@ -2934,7 +2930,7 @@ get(key: string, callback: AsyncCallback<Uint8Array | string | boolean | numb 获取指定键的值,并通过callback方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -2972,7 +2968,7 @@ get(key: string): Promise<Uint8Array | string | boolean | number> 获取指定键的值,并通过Promise方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -3015,7 +3011,7 @@ getEntries(keyPrefix: string, callback: AsyncCallback<Entry[]>): void 获取匹配指定键前缀的所有键值对,并通过callback方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -3061,7 +3057,7 @@ getEntries(keyPrefix: string): Promise<Entry[]> 获取匹配指定键前缀的所有键值对,并通过Promise方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -3117,9 +3113,9 @@ try { getEntries(query: Query, callback: AsyncCallback<Entry[]>): void -获取与指定 Query 对象匹配的键值对列表,并通过callback方式返回,此方法为异步方法。 +获取与指定Query对象匹配的键值对列表,并通过callback方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -3221,13 +3217,13 @@ try { ``` -### getResultSet8+ ### +### getResultSet8+ ### getResultSet(keyPrefix: string, callback: AsyncCallback<KvStoreResultSet>): void -从 KvStore 数据库中获取具有指定前缀的结果集,并通过callback方式返回,此方法为异步方法。 +从KvStore数据库中获取具有指定前缀的结果集,并通过callback方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -3257,7 +3253,7 @@ try { kvStore.putBatch(entries, async function (err, data) { console.log('GetResultSet putBatch success'); await kvStore.getResultSet('batch_test_string_key', async function (err, result) { - console.log('GetResultSet getResultSet success'); + console.log('GetResultSet getResultSet succeed.'); resultSet = result; kvStore.closeResultSet(resultSet, function (err, data) { console.log('GetResultSet closeResultSet success'); @@ -3274,9 +3270,9 @@ try { getResultSet(keyPrefix: string): Promise<KvStoreResultSet> -从 KVStore 数据库中获取具有指定前缀的结果集,并通过Promise方式返回,此方法为异步方法。 +从KVStore数据库中获取具有指定前缀的结果集,并通过Promise方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -3314,10 +3310,10 @@ try { console.log('PutBatch putBatch fail ' + JSON.stringify(err)); }); kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('GetResult getResultSet success'); + console.log('GetResult getResultSet succeed.'); resultSet = result; }).catch((err) => { - console.log('getResultSet fail ' + JSON.stringify(err)); + console.log('getResultSet failed: ' + JSON.stringify(err)); }); kvStore.closeResultSet(resultSet).then((err) => { console.log('GetResult closeResultSet success'); @@ -3334,16 +3330,16 @@ try { getResultSet(query: Query, callback: AsyncCallback<KvStoreResultSet>): void -获取与指定 Query 对象匹配的 KvStoreResultSet 对象,并通过callback方式返回,此方法为异步方法。 +获取与指定Query对象匹配的KvStoreResultSet对象,并通过callback方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | query |Query | 是 |表示查询对象。 | -| callback |AsyncCallback<[KvStoreResultSet](#kvstoreresultset8)> | 是 |回调函数,获取与指定 Query 对象匹配的 KvStoreResultSet 对象。 | +| callback |AsyncCallback<[KvStoreResultSet](#kvstoreresultset8)> | 是 |回调函数,获取与指定Query对象匹配的KvStoreResultSet对象。 | **示例:** @@ -3368,7 +3364,7 @@ try { const query = new distributedData.Query(); query.prefixKey("batch_test"); await kvStore.getResultSet(query, async function (err, result) { - console.log('getResultSet success'); + console.log('getResultSet succeed.'); resultSet = result; }); }); @@ -3382,9 +3378,9 @@ try { getResultSet(query: Query): Promise<KvStoreResultSet> -获取与指定 Query 对象匹配的 KvStoreResultSet 对象,并通过Promise方式返回,此方法为异步方法。 +获取与指定Query对象匹配的KvStoreResultSet对象,并通过Promise方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -3424,10 +3420,10 @@ try { const query = new distributedData.Query(); query.prefixKey("batch_test"); kvStore.getResultSet(query).then((result) => { - console.log(' getResultSet success'); + console.log(' getResultSet succeed.'); resultSet = result; }).catch((err) => { - console.log('getResultSet fail ' + JSON.stringify(err)); + console.log('getResultSet failed: ' + JSON.stringify(err)); }); }catch(e) { console.log('GetResultSet e ' + e); @@ -3438,16 +3434,16 @@ try { closeResultSet(resultSet: KvStoreResultSet, callback: AsyncCallback<void>): void -关闭由 getResultSet 返回的 KvStoreResultSet 对象,并通过callback方式返回,此方法为异步方法。 +关闭由[SingleKvStore.getResultSet](#singlekvstore_getresultset)返回的KvStoreResultSet对象,并通过callback方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | -| resultSet |[KvStoreResultSet](#kvstoreresultset8) | 是 |表示要关闭的 KvStoreResultSet 对象。 | -| callback |AsyncCallback<void> | 是 |回调函数,获取由 getResultSet 返回的 KvStoreResultSet 对象。 | +| resultSet |[KvStoreResultSet](#kvstoreresultset8) | 是 |表示要关闭的KvStoreResultSet对象。 | +| callback |AsyncCallback<void> | 是 |回调函数。 | **示例:** @@ -3472,15 +3468,15 @@ try { closeResultSet(resultSet: KvStoreResultSet): Promise<void> -关闭由 getResultSet 返回的 KvStoreResultSet 对象,并通过Promise方式返回,此方法为异步方法。 +关闭由[SingleKvStore.getResultSet](#singlekvstore_getresultset)返回的KvStoreResultSet对象,并通过Promise方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | -| resultSet |[KvStoreResultSet](#kvstoreresultset8) | 是 |表示要关闭的 KvStoreResultSet 对象。 | +| resultSet |[KvStoreResultSet](#kvstoreresultset8) | 是 |表示要关闭的KvStoreResultSet对象。 | **返回值:** @@ -3509,16 +3505,16 @@ try { getResultSize(query: Query, callback: AsyncCallback<number>): void -获取与指定 Query 对象匹配的结果数,并通过callback方式返回,此方法为异步方法。 +获取与指定Query对象匹配的结果数,并通过callback方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | query |[Query](#query8) | 是 |表示查询对象。 | -| callback |AsyncCallback<number> | 是 |回调函数,获取与指定 Query 对象匹配的结果数。 | +| callback |AsyncCallback<number> | 是 |回调函数,获取与指定Query对象匹配的结果数。 | **示例:** @@ -3542,7 +3538,7 @@ try { const query = new distributedData.Query(); query.prefixKey("batch_test"); await kvStore.getResultSize(query, async function (err, resultSize) { - console.log('getResultSet success'); + console.log('getResultSet succeed.'); }); }); } catch(e) { @@ -3555,9 +3551,9 @@ try { getResultSize(query: Query): Promise<number> -获取与指定 Query 对象匹配的结果数,并通过Promise方式返回,此方法为异步方法。 +获取与指定Query对象匹配的结果数,并通过Promise方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -3596,9 +3592,9 @@ try { const query = new distributedData.Query(); query.prefixKey("batch_test"); kvStore.getResultSize(query).then((resultSize) => { - console.log('getResultSet success'); + console.log('getResultSet succeed.'); }).catch((err) => { - console.log('getResultSet fail ' + JSON.stringify(err)); + console.log('getResultSet failed: ' + JSON.stringify(err)); }); }catch(e) { console.log('GetResultSize e ' + e); @@ -3612,7 +3608,7 @@ removeDeviceData(deviceId: string, callback: AsyncCallback<void>): void 删除指定设备的数据,并通过callback方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -3654,7 +3650,7 @@ removeDeviceData(deviceId: string): Promise<void> 删除指定设备的数据,并通过Promise方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -3703,7 +3699,7 @@ on(event: 'syncComplete', syncCallback: Callback<Array<[string, number]> 订阅同步完成事件回调通知,此方法为同步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -3739,7 +3735,7 @@ off(event: 'syncComplete', syncCallback?: Callback<Array<[string, number]& 取消订阅同步完成事件回调通知,此方法为同步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -3768,18 +3764,18 @@ try { sync(deviceIdList: string[], mode: SyncMode, allowedDelayMs?: number): void -在手动模式下,触发数据库同步,此方法为同步方法。 +在手动同步方式下,触发数据库同步,此方法为同步方法。关于分布式数据服务的同步方式说明,请见[分布式数据服务概述](../../database/database-mdds-overview.md)。 **需要权限**: ohos.permission.DISTRIBUTED_DATASYNC。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | deviceIdList |string[] | 是 |同一组网环境下,需要同步的设备的deviceId列表。 | -| mode |[SyncMode](#syncmode) | 是 |同步类型。 | +| mode |[SyncMode](#syncmode) | 是 |同步模式。 | | allowedDelayMs |number | 否 |可选参数,允许延时时间,单位:ms(毫秒)。 | **示例:** @@ -3793,9 +3789,9 @@ kvStore.sync('deviceIds', distributedData.SyncMode.PULL_ONLY, 1000); setSyncParam(defaultAllowedDelayMs: number, callback: AsyncCallback<void>): void -设置允许数据库同步的默认延迟,并通过callback方式返回,此方法为异步方法。 +设置数据库同步允许的默认延迟,并通过callback方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -3823,9 +3819,9 @@ try { setSyncParam(defaultAllowedDelayMs: number): Promise<void> -设置允许数据库同步的默认延迟,并通过Promise方式返回,此方法为异步方法。 +设置数据库同步允许的默认延迟,并通过Promise方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -3863,7 +3859,7 @@ getSecurityLevel(callback: AsyncCallback<SecurityLevel>): void 获取数据库的安全级别,并通过callback方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -3891,7 +3887,7 @@ getSecurityLevel(): Promise<SecurityLevel> 获取数据库的安全级别,并通过Promise方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **返回值:** @@ -3919,22 +3915,20 @@ try { 在分布式系统中按设备管理分布式数据,继承自KVStore,提供查询数据和同步数据的方法。在调用DeviceKVStore的方法前,需要先通过[getKVStore](#getkvstore)构建一个DeviceKVStore实例。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 - ### get8+ ### get(deviceId: string, key: string, callback: AsyncCallback<boolean|string|number|Uint8Array>): void -获取与指定设备 ID 和 key 匹配的 String 值,并通过callback方式返回,此方法为异步方法。 +获取与指定设备ID和key匹配的string值,并通过callback方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore **参数:** | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | deviceId |string | 是 |标识要查询其数据的设备。 | -| key |string | 是 |表示要查询 key 值的键。 | +| key |string | 是 |表示要查询key值的键。 | | callback |AsyncCallback<boolean\|string\|number\|Uint8Array> | 是 |回调函数,返回匹配给定条件的字符串值。 | **示例:** @@ -3960,16 +3954,16 @@ try{ get(deviceId: string, key: string): Promise<boolean|string|number|Uint8Array> -获取与指定设备 ID 和 key 匹配的 String 值,并通过Promise方式返回,此方法为异步方法。 +获取与指定设备ID和key匹配的string值,并通过Promise方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore **参数:** | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | deviceId |string | 是 |标识要查询其数据的设备。 | -| key |string | 是 |表示要查询 key 值的键。 | +| key |string | 是 |表示要查询key值的键。 | **返回值:** @@ -4004,9 +3998,9 @@ try { getEntries(deviceId: string, keyPrefix: string, callback: AsyncCallback<Entry[]>): void -获取与指定设备 ID 和 key 前缀匹配的所有键值对,并通过callback方式返回,此方法为异步方法。 +获取与指定设备ID和key前缀匹配的所有键值对,并通过callback方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore **参数:** @@ -4052,9 +4046,9 @@ try { getEntries(deviceId: string, keyPrefix: string): Promise<Entry[]> -获取与指定设备 ID 和 key 前缀匹配的所有键值对,并通过Promise方式返回,此方法为异步方法。 +获取与指定设备ID和key前缀匹配的所有键值对,并通过Promise方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore **参数:** @@ -4111,16 +4105,16 @@ try { getEntries(query: Query, callback: AsyncCallback<Entry[]>): void -获取与指定 Query 对象匹配的键值对列表,并通过callback方式返回,此方法为异步方法。 +获取与指定Query对象匹配的键值对列表,并通过callback方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore **参数:** | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | query |[Query](#query8) | 是 |表示查询对象。 | -| callback |AsyncCallback<[Entry](#entry)[]> | 是 |回调函数,返回与指定 Query 对象匹配的键值对列表。 | +| callback |AsyncCallback<[Entry](#entry)[]> | 是 |回调函数,返回与指定Query对象匹配的键值对列表。 | **示例:** @@ -4164,9 +4158,9 @@ try { getEntries(query: Query): Promise<Entry[]> -获取与指定 Query 对象匹配的键值对列表,并通过Promise方式返回,此方法为异步方法。 +获取与指定Query对象匹配的键值对列表,并通过Promise方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore **参数:** @@ -4222,9 +4216,9 @@ try { getEntries(deviceId: string, query: Query, callback: AsyncCallback<Entry[]>): void -获取与指定设备 ID 和 Query 对象匹配的键值对列表,并通过callback方式返回,此方法为异步方法。 +获取与指定设备ID和Query对象匹配的键值对列表,并通过callback方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore **参数:** @@ -4232,7 +4226,7 @@ getEntries(deviceId: string, query: Query, callback: AsyncCallback<Entry[]> | ----- | ------ | ---- | ----------------------- | | deviceId |string | 是 |键值对所属的设备ID。 | | query |[Query](#query8) | 是 |表示查询对象。 | -| callback |AsyncCallback<[Entry](#entry)[]> | 是 |回调函数,返回与指定 Query 对象匹配的键值对列表。 | +| callback |AsyncCallback<[Entry](#entry)[]> | 是 |回调函数,返回与指定Query对象匹配的键值对列表。 | **示例:** @@ -4276,9 +4270,9 @@ try { getEntries(deviceId: string, query: Query): Promise<Entry[]> -获取与指定设备 ID 和 Query 对象匹配的键值对列表,并通过Promise方式返回,此方法为异步方法。 +获取与指定设备ID和Query对象匹配的键值对列表,并通过Promise方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore **参数:** @@ -4332,13 +4326,13 @@ try { ``` -### getResultSet8+ ### +### getResultSet8+ ### getResultSet(deviceId: string, keyPrefix: string, callback: AsyncCallback<KvStoreResultSet>): void -获取与指定设备 ID 和 key 前缀匹配的 KvStoreResultSet 对象,并通过callback方式返回,此方法为异步方法。 +获取与指定设备ID和key前缀匹配的KvStoreResultSet对象,并通过callback方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore **参数:** @@ -4346,7 +4340,7 @@ getResultSet(deviceId: string, keyPrefix: string, callback: AsyncCallback<KvS | ----- | ------ | ---- | ----------------------- | | deviceId |string | 是 |标识要查询其数据的设备。 | | keyPrefix |string | 是 |表示要匹配的键前缀。 | -| callback |AsyncCallback<[KvStoreResultSet](#kvstoreresultset8)[]> | 是 |回调函数,返回 KvStoreResultSet 对象。 | +| callback |AsyncCallback<[KvStoreResultSet](#kvstoreresultset8)[]> | 是 |回调函数,返回KvStoreResultSet对象。 | **示例:** @@ -4355,7 +4349,7 @@ let kvStore; try { let resultSet; kvStore.getResultSet('localDeviceId', 'batch_test_string_key', async function (err, result) { - console.log('getResultSet success'); + console.log('getResultSet succeed.'); resultSet = result; await kvStore.closeResultSet(resultSet, function (err, data) { console.log('closeResultSet success'); @@ -4371,9 +4365,9 @@ try { getResultSet(deviceId: string, keyPrefix: string): Promise<KvStoreResultSet> -获取与指定设备 ID 和 key 前缀匹配的 KvStoreResultSet 对象,并通过Promise方式返回,此方法为异步方法。 +获取与指定设备ID和key前缀匹配的KvStoreResultSet对象,并通过Promise方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore **参数:** @@ -4395,10 +4389,10 @@ let kvStore; try { let resultSet; kvStore.getResultSet('localDeviceId', 'batch_test_string_key').then((result) => { - console.log('getResultSet success'); + console.log('getResultSet succeed.'); resultSet = result; }).catch((err) => { - console.log('getResultSet fail ' + JSON.stringify(err)); + console.log('getResultSet failed: ' + JSON.stringify(err)); }); kvStore.closeResultSet(resultSet).then((err) => { console.log('closeResultSet success'); @@ -4415,16 +4409,16 @@ try { getResultSet(query: Query, callback: AsyncCallback<KvStoreResultSet>): void -获取与指定 Query 对象匹配的 KvStoreResultSet 对象,并通过callback方式返回,此方法为异步方法。 +获取与指定Query对象匹配的KvStoreResultSet对象,并通过callback方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore **参数:** | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | query |[Query](#query8) | 是 |表示查询对象。 | -| callback |AsyncCallback<[KvStoreResultSet](#kvstoreresultset8)[]> | 是 |回调函数,返回与指定 Query 对象匹配的 KvStoreResultSet 对象。 | +| callback |AsyncCallback<[KvStoreResultSet](#kvstoreresultset8)[]> | 是 |回调函数,返回与指定Query对象匹配的KvStoreResultSet对象。 | **示例:** @@ -4450,7 +4444,7 @@ try { query.prefixKey("batch_test"); query.deviceId('localDeviceId'); await kvStore.getResultSet(query, async function (err, result) { - console.log('getResultSet success'); + console.log('getResultSet succeed.'); resultSet = result; await kvStore.closeResultSet(resultSet, function (err, data) { console.log('closeResultSet success'); @@ -4467,9 +4461,9 @@ try { getResultSet(query: Query): Promise<KvStoreResultSet> -获取与指定 Query 对象匹配的 KvStoreResultSet 对象,并通过Promise方式返回,此方法为异步方法。 +获取与指定Query对象匹配的KvStoreResultSet对象,并通过Promise方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore **参数:** @@ -4511,10 +4505,10 @@ try { query.prefixKey("batch_test"); console.log("GetResultSet " + query.getSqlLike()); kvStore.getResultSet(query).then((result) => { - console.log('getResultSet success'); + console.log('getResultSet succeed.'); resultSet = result; }).catch((err) => { - console.log('getResultSet fail ' + JSON.stringify(err)); + console.log('getResultSet failed: ' + JSON.stringify(err)); }); kvStore.closeResultSet(resultSet).then((err) => { console.log('closeResultSet success'); @@ -4533,7 +4527,7 @@ getResultSet(deviceId: string, query: Query, callback: AsyncCallback<KvStoreR 获取与指定设备ID和Query对象匹配的KvStoreResultSet对象,并通过callback方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore **参数:** @@ -4541,7 +4535,7 @@ getResultSet(deviceId: string, query: Query, callback: AsyncCallback<KvStoreR | ----- | ------ | ---- | ----------------------- | | deviceId |string | 是 |KvStoreResultSet对象所属的设备ID。 | | query |[Query](#query8) | 是 |表示查询对象。 | -| callback |AsyncCallback<[KvStoreResultSet](#kvstoreresultset8)[]> | 是 |回调函数,返回与指定 Query 对象匹配的 KvStoreResultSet 对象。 | +| callback |AsyncCallback<[KvStoreResultSet](#kvstoreresultset8)[]> | 是 |回调函数,返回与指定Query对象匹配的KvStoreResultSet对象。 | **示例:** @@ -4566,7 +4560,7 @@ try { const query = new distributedData.Query(); query.prefixKey("batch_test"); await kvStore.getResultSet('localDeviceId', query, async function (err, result) { - console.log('getResultSet success'); + console.log('getResultSet succeed.'); resultSet = result; await kvStore.closeResultSet(resultSet, function (err, data) { console.log('closeResultSet success'); @@ -4585,7 +4579,7 @@ getResultSet(deviceId: string, query: Query): Promise<KvStoreResultSet> 获取与指定设备ID和Query对象匹配的KvStoreResultSet对象,并通过Promise方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore **参数:** @@ -4626,10 +4620,10 @@ try { const query = new distributedData.Query(); query.prefixKey("batch_test"); kvStore.getResultSet('localDeviceId', query).then((result) => { - console.log('GetResultSet getResultSet success'); + console.log('GetResultSet getResultSet succeed.'); resultSet = result; }).catch((err) => { - console.log('GetResultSet getResultSet fail ' + JSON.stringify(err)); + console.log('GetResultSet getResultSet failed: ' + JSON.stringify(err)); }); query.deviceId('localDeviceId'); console.log("GetResultSet " + query.getSqlLike()); @@ -4649,15 +4643,15 @@ try { closeResultSet(resultSet: KvStoreResultSet, callback: AsyncCallback<void>): void -关闭由 getResultSet 返回的 KvStoreResultSet 对象,并通过callback方式返回,此方法为异步方法。 +关闭由[DeviceKVStore.getResultSet](#devicekvstore_getresultset)返回的KvStoreResultSet对象,并通过callback方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore **参数:** | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | -| resultSet |[KvStoreResultSet](#getresultset8) | 是 |指示要关闭的 KvStoreResultSet 对象。 | +| resultSet |[KvStoreResultSet](#getresultset8) | 是 |指示要关闭的KvStoreResultSet对象。 | | callback |AsyncCallback<void> | 是 |回调函数。 | **示例:** @@ -4684,15 +4678,15 @@ try { closeResultSet(resultSet: KvStoreResultSet): Promise<void> -关闭由 getResultSet 返回的 KvStoreResultSet 对象,并通过Promise方式返回,此方法为异步方法。 +关闭由[DeviceKVStore.getResultSet](#devicekvstore_getresultset)返回的KvStoreResultSet对象,并通过Promise方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore **参数:** | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | -| resultSet |[KvStoreResultSet](#getresultset8) | 是 |指示要关闭的 KvStoreResultSet 对象。 | +| resultSet |[KvStoreResultSet](#getresultset8) | 是 |指示要关闭的KvStoreResultSet对象。 | **返回值:** @@ -4722,16 +4716,16 @@ try { getResultSize(query: Query, callback: AsyncCallback<number>): void -获取与指定 Query 对象匹配的结果数,并通过callback方式返回,此方法为异步方法。 +获取与指定Query对象匹配的结果数,并通过callback方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore **参数:** | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | query |[Query](#query8) | 是 |表示查询对象。 | -| callback |AsyncCallback<number> | 是 |回调函数,返回与指定 Query 对象匹配的结果数。 | +| callback |AsyncCallback<number> | 是 |回调函数,返回与指定Query对象匹配的结果数。 | **示例:** @@ -4756,7 +4750,7 @@ try { query.prefixKey("batch_test"); query.deviceId('localDeviceId'); await kvStore.getResultSize(query, async function (err, resultSize) { - console.log('getResultSet success'); + console.log('getResultSet succeed.'); }); }); } catch(e) { @@ -4769,9 +4763,9 @@ try { getResultSize(query: Query): Promise<number> -获取与指定 Query 对象匹配的结果数,并通过Promise方式返回,此方法为异步方法。 +获取与指定Query对象匹配的结果数,并通过Promise方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore **参数:** @@ -4811,9 +4805,9 @@ try { query.prefixKey("batch_test"); query.deviceId('localDeviceId'); kvStore.getResultSize(query).then((resultSize) => { - console.log('getResultSet success'); + console.log('getResultSet succeed.'); }).catch((err) => { - console.log('getResultSet fail ' + JSON.stringify(err)); + console.log('getResultSet failed: ' + JSON.stringify(err)); }); }catch(e) { console.log('GetResultSize e ' + e); @@ -4825,9 +4819,9 @@ try { getResultSize(deviceId: string, query: Query, callback: AsyncCallback<number>): void; -获取与指定设备 ID 和 Query 对象匹配的结果数,并通过callback方式返回,此方法为异步方法。 +获取与指定设备ID和Query对象匹配的结果数,并通过callback方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore **参数:** @@ -4835,7 +4829,7 @@ getResultSize(deviceId: string, query: Query, callback: AsyncCallback<number& | ----- | ------ | ---- | ----------------------- | | deviceId |string | 是 |KvStoreResultSet对象所属的设备ID。 | | query |[Query](#query8) | 是 |表示查询对象。 | -| callback |AsyncCallback<number> | 是 |回调函数,返回与指定 Query 对象匹配的结果数。 | +| callback |AsyncCallback<number> | 是 |回调函数,返回与指定Query对象匹配的结果数。 | **示例:** @@ -4859,7 +4853,7 @@ try { const query = new distributedData.Query(); query.prefixKey("batch_test"); await kvStore.getResultSize('localDeviceId', query, async function (err, resultSize) { - console.log('getResultSet success'); + console.log('getResultSet succeed.'); }); }); } catch(e) { @@ -4872,9 +4866,9 @@ try { getResultSize(deviceId: string, query: Query): Promise<number> -获取与指定设备 ID 和 Query 对象匹配的结果数,并通过Promise方式返回,此方法为异步方法。 +获取与指定设备ID和Query对象匹配的结果数,并通过Promise方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore **参数:** @@ -4914,9 +4908,9 @@ try { var query = new distributedData.Query(); query.prefixKey("batch_test"); kvStore.getResultSize('localDeviceId', query).then((resultSize) => { - console.log('getResultSet success'); + console.log('getResultSet succeed.'); }).catch((err) => { - console.log('getResultSet fail ' + JSON.stringify(err)); + console.log('getResultSet failed: ' + JSON.stringify(err)); }); }catch(e) { console.log('GetResultSize e ' + e); @@ -4930,7 +4924,7 @@ removeDeviceData(deviceId: string, callback: AsyncCallback<void>): void 从当前数据库中删除指定设备的数据,并通过callback方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore **参数:** @@ -4972,7 +4966,7 @@ removeDeviceData(deviceId: string): Promise<void> 从当前数据库中删除指定设备的数据,并通过Promise方式返回,此方法为异步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore **参数:** @@ -5019,18 +5013,18 @@ try { sync(deviceIdList: string[], mode: SyncMode, allowedDelayMs?: number): void -在手动模式下,触发数据库同步,此方法为同步方法。 +在手动同步方式下,触发数据库同步,此方法为同步方法。关于分布式数据服务的同步方式说明,请见[分布式数据服务概述](../../database/database-mdds-overview.md)。 **需要权限**: ohos.permission.DISTRIBUTED_DATASYNC。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** | 参数名 | 参数类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | deviceIdList |string[] | 是 |需要同步DeviceKvStore数据库的设备ID列表。 | -| mode |[SyncMode](#syncmode) | 是 |表示同步方式,PUSH、PULL或PUSH_PULL。 | +| mode |[SyncMode](#syncmode) | 是 |同步模式。 | | allowedDelayMs |number | 否 |可选参数,允许延时时间,单位:ms(毫秒)。 | **示例:** @@ -5060,7 +5054,7 @@ on(event: 'syncComplete', syncCallback: Callback<Array<[string, number]> 订阅同步完成事件回调通知,该方法为同步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -5095,7 +5089,7 @@ off(event: 'syncComplete', syncCallback?: Callback<Array<[string, number]& 取消订阅同步完成事件回调通知,该方法为同步方法。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core。 +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** @@ -5122,7 +5116,7 @@ try { ## SyncMode -用于指定同步模式。 +同步模式枚举。 **系统能力:** 以下各项对应的系统能力均为 SystemCapability.DistributedDataManager.KVStore.Core。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-enterprise-device-manager.md b/zh-cn/application-dev/reference/apis/js-apis-enterprise-device-manager.md index d0fb55a47dde7eb4277a3fd98f065286543e3724..bc8c445747e2c5f31cecea108d776ddce2de8957 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-enterprise-device-manager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-enterprise-device-manager.md @@ -550,7 +550,7 @@ enterpriseDeviceManager.getEnterpriseInfo(wantTemp, (error, result) => { ## enterpriseDeviceManager.getEnterpriseInfo -getDeviceSettingsManager(admin: Want): Promise<EnterpriseInfo> +getEnterpriseInfo(admin: Want): Promise<EnterpriseInfo> 获取设备管理员应用的企业信息,使用Promise形式返回设备管理员应用的企业信息。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-eventhub.md b/zh-cn/application-dev/reference/apis/js-apis-eventhub.md index 0a1ed1adcc6b998d195a011bd6eccf4bc8ecf7ae..a32d3f6625b57589b433450879bf404327416ee3 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-eventhub.md +++ b/zh-cn/application-dev/reference/apis/js-apis-eventhub.md @@ -6,6 +6,11 @@ 事件中心,提供订阅、取消订阅、触发事件能力。 +## 导入模块 + +```js +import EventHub from "@ohos.application.eventHub"; +``` ## 使用说明 diff --git a/zh-cn/application-dev/reference/apis/js-apis-extension-context.md b/zh-cn/application-dev/reference/apis/js-apis-extension-context.md index cae9ac3e37de8e608a3d6905b35a576466652d33..30f71ae5d6c6c6d0608948f8dbb845422ec072ff 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-extension-context.md +++ b/zh-cn/application-dev/reference/apis/js-apis-extension-context.md @@ -6,6 +6,11 @@ Extension的上下文环境,继承自Context。 +## 导入模块 + +```js +import ExtensionContext from "@ohos.application.extensionContext"; +``` ## 属性 diff --git a/zh-cn/application-dev/reference/apis/js-apis-extensionrunninginfo.md b/zh-cn/application-dev/reference/apis/js-apis-extensionrunninginfo.md index 5ebfc6c87bebd752e1e8e65aaa22130d748a333d..60d27d15d902696233afdfb8688426b31d615f7b 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-extensionrunninginfo.md +++ b/zh-cn/application-dev/reference/apis/js-apis-extensionrunninginfo.md @@ -6,6 +6,11 @@ Extension运行相关信息。 +## 导入模块 + +```js +import ExtensionRunningInfo from "@ohos.application.extensionRunningInfo"; +``` ## 使用说明 diff --git a/zh-cn/application-dev/reference/apis/js-apis-formextension.md b/zh-cn/application-dev/reference/apis/js-apis-formextension.md index 5062f58bf778060f1a3aaff6fb005df79f101c20..815fe17f87118c38c97cf9c3e7b14d2e48537091 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-formextension.md +++ b/zh-cn/application-dev/reference/apis/js-apis-formextension.md @@ -218,4 +218,28 @@ onConfigurationUpdated(config: Configuration): void; console.log('onConfigurationUpdated, config:' + JSON.stringify(config)); } } + ``` + + ## FormExtension.onAcquireFormState + +onAcquireFormState?(want: Want): formInfo.FormState; + +返回formInfo#FormState对象。 + +**系统能力**:SystemCapability.Ability.Form + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | want | [Want](js-apis-application-Want.md) | 否 | 返回formInfo#FormState对象。 | + +**示例:** + + ```js + class MyFormExtension extends MyFormExtension { + onAcquireFormState(want) { + console.log('FormExtension onAcquireFormState, want:' + want); + } + } ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-formextensioncontext.md b/zh-cn/application-dev/reference/apis/js-apis-formextensioncontext.md index 9297f798d3285c3661bad86d8d62a998d1ab8273..4d9c8bf0ee8dce537fd92f5843141723ca4645bb 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-formextensioncontext.md +++ b/zh-cn/application-dev/reference/apis/js-apis-formextensioncontext.md @@ -5,6 +5,12 @@ FormExtension的上下文环境,提供FormExtension具有的能力和接口,继承自ExtensionContext。 +## 导入模块 + +```js +import FormExtensionContext from '@ohos.application.formExtensionContext'; +``` + ## FormExtensionContext.updateForm updateForm(formId: string, formBindingData: formBindingData.FormBindingData, callback: AsyncCallback\): void diff --git a/zh-cn/application-dev/reference/apis/js-apis-formhost.md b/zh-cn/application-dev/reference/apis/js-apis-formhost.md index 58a427d6dd0336bc89152f6881b0187ae8f9230c..9720fe8b6dee7508d35318e338f2902b1b196529 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-formhost.md +++ b/zh-cn/application-dev/reference/apis/js-apis-formhost.md @@ -591,7 +591,7 @@ SystemCapability.Ability.Form ## getAllFormsInfo -getAllFormsInfo(callback: AsyncCallback<Array<FormInfo>>): void; +getAllFormsInfo(callback: AsyncCallback<Array<formInfo.FormInfo>>): void; 获取设备上所有应用提供的卡片信息。 @@ -619,7 +619,8 @@ SystemCapability.Ability.Form ## getAllFormsInfo -getAllFormsInfo(): Promise<Array<FormInfo>>; +getAllFormsInfo(): Promise<Array<formInfo.FormInfo>>; + 获取设备上所有应用提供的卡片信息。 @@ -645,7 +646,8 @@ SystemCapability.Ability.Form ## getFormsInfo -getFormsInfo(bundleName: string, callback: AsyncCallback<Array<FormInfo>>): void; +getFormsInfo(bundleName: string, callback: AsyncCallback<Array<formInfo.FormInfo>>): void; + 获取设备上指定应用程序提供的卡片信息。 @@ -674,7 +676,8 @@ SystemCapability.Ability.Form ## getFormsInfo -getFormsInfo(bundleName: string, moduleName: string, callback: AsyncCallback<Array<FormInfo>>): void; +getFormsInfo(bundleName: string, moduleName: string, callback: AsyncCallback<Array<formInfo.FormInfo>>): void; + 获取设备上指定应用程序提供的卡片信息。 @@ -704,7 +707,8 @@ SystemCapability.Ability.Form ## getFormsInfo -getFormsInfo(bundleName: string, moduleName?: string): Promise<Array<FormInfo>>; +getFormsInfo(bundleName: string, moduleName?: string): Promise<Array<formInfo.FormInfo>>; + 获取设备上指定应用程序提供的卡片信息。 @@ -767,7 +771,7 @@ SystemCapability.Ability.Form ## deleteInvalidForms -function deleteInvalidForms(formIds: Array<string>): Promise<number>; +deleteInvalidForms(formIds: Array<string>): Promise<number>; 根据列表删除应用程序的无效卡片。 @@ -800,7 +804,7 @@ SystemCapability.Ability.Form ## acquireFormState -acquireFormState(want: Want, callback: AsyncCallback<FormStateInfo>): void; +acquireFormState(want: Want, callback: AsyncCallback<formInfo.FormStateInfo>): void; 获取卡片状态 @@ -834,7 +838,7 @@ SystemCapability.Ability.Form ## acquireFormState -function acquireFormState(want: Want): Promise<FormStateInfo>; +acquireFormState(want: Want): Promise<formInfo.FormStateInfo>; 获取卡片状态。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-formprovider.md b/zh-cn/application-dev/reference/apis/js-apis-formprovider.md index 197ab4e0c353c20b0e61f34ea2b93bc7a3de52c8..253c97bf7f1f690670d1511d28ee48ce7afbcf8a 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-formprovider.md +++ b/zh-cn/application-dev/reference/apis/js-apis-formprovider.md @@ -80,7 +80,7 @@ SystemCapability.Ability.Form ## updateForm -updateForm(formId: string, formBindingData: FormBindingData, callback: AsyncCallback<void>): void; +updateForm(formId: string, formBindingData: formBindingData.FormBindingData,callback: AsyncCallback<void>): void; 更新指定的卡片。 @@ -111,7 +111,7 @@ SystemCapability.Ability.Form ## updateForm -updateForm(formId: string, formBindingData: FormBindingData): Promise<void>; +updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Promise<void>; 更新指定的卡片,以promise方式返回。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-hichecker.md b/zh-cn/application-dev/reference/apis/js-apis-hichecker.md index 61526dd638ce66cddb70e40d2b56f27e18864488..ab3edd6a3ddc5cdd83618d04881f380cbb77b8b3 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-hichecker.md +++ b/zh-cn/application-dev/reference/apis/js-apis-hichecker.md @@ -1,5 +1,7 @@ # 检测模式 +HiChecker可以作为应用开发阶段使用的检测工具,用于检测代码运行过程中部分易忽略的问题,如应用线程出现耗时调用、应用进程中Ability资源泄露等问题。开发者可以通过日志记录或进程crash等形式查看具体问题并进行修改,提升应用的使用体验。 + > **说明:** > 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 @@ -15,20 +17,19 @@ import hichecker from '@ohos.hichecker'; 提供了所有规则类型的常量。 -**系统能力:** 以下各项对应的系统能力均为SystemCapability.HiviewDFX.HiChecker。 +**系统能力:** SystemCapability.HiviewDFX.HiChecker | 名称 | 参数类型 | 说明 | | ---------------------------------- | -------- | ------------------------------------------------------ | -| RULE_CAUTION_PRINT_LOG | BigInt | 告警规则,当有告警时记录日志。 | -| RULE_CAUTION_TRIGGER_CRASH | BigInt | 告警规则,当有告警时让应用推出。 | -| RULE_THREAD_CHECK_SLOW_PROCESS | BigInt | 检测规则,检测是否有耗时函数被调用。 | -| RULE_CHECK_SLOW_EVENT | BigInt | 检测规则,检测是否有事件分发或处理超过规定的时间阈值。 | -| RULE_CHECK_ABILITY_CONNECTION_LEAK | BigInt | 检测规则,检测是否发生ability泄露。 | +| RULE_CAUTION_PRINT_LOG | bigInt | 告警规则,当有告警时记录日志。 | +| RULE_CAUTION_TRIGGER_CRASH | bigInt | 告警规则,当有告警时让应用推出。 | +| RULE_THREAD_CHECK_SLOW_PROCESS | bigInt | 检测规则,检测是否有耗时函数被调用。 | +| RULE_CHECK_ABILITY_CONNECTION_LEAK | bigInt | 检测规则,检测是否发生ability泄露。 | ## hichecker.addRule -addRule(rule: BigInt): void +addRule(rule: bigInt): void 添加一条或多条规则到系统,系统根据添加的规则进行检测或反馈。 @@ -38,7 +39,7 @@ addRule(rule: BigInt): void | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ---------------- | -| rule | BigInt | 是 | 需要添加的规则。 | +| rule | bigInt | 是 | 需要添加的规则。 | **示例:** @@ -53,7 +54,7 @@ hichecker.addRule( ## hichecker.removeRule -removeRule(rule: BigInt): void +removeRule(rule: bigInt): void 删除一条或多条规则,删除的规则后续将不再生效。 @@ -63,7 +64,7 @@ removeRule(rule: BigInt): void | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ---------------- | -| rule | BigInt | 是 | 需要删除的规则。 | +| rule | bigInt | 是 | 需要删除的规则。 | **示例:** @@ -78,7 +79,7 @@ hichecker.removeRule( ## hichecker.getRule -getRule(): BigInt +getRule(): bigInt 获取当前线程规则、进程规则、告警规则的合集。 @@ -88,7 +89,7 @@ getRule(): BigInt | 类型 | 说明 | | ------ | ---------------------- | -| BigInt | 当前系统中添加的规则。 | +| bigInt | 当前系统中添加的规则。 | **示例:** @@ -102,7 +103,7 @@ hichecker.getRule(); // return 1n; ## hichecker.contains -contains(rule: BigInt): boolean +contains(rule: bigInt): boolean 当前已添加的规则集中是否包含了某一个特定的规则,如果传入的规则级别为线程级别,则仅在当前线程中进行查询。 @@ -112,7 +113,7 @@ contains(rule: BigInt): boolean | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ---------------- | -| rule | BigInt | 是 | 需要查询的规则。 | +| rule | bigInt | 是 | 需要查询的规则。 | **返回值:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-hilog.md b/zh-cn/application-dev/reference/apis/js-apis-hilog.md index 7c4caaf8d5579f259df88f87602ce8c447bfa38c..ad45774b8dce4261d453deb6642dc504b4e46fd2 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-hilog.md +++ b/zh-cn/application-dev/reference/apis/js-apis-hilog.md @@ -1,7 +1,9 @@ # 日志打印 +hilog日志系统,使应用/服务可以按照指定级别、标识和格式字符串输出日志内容,帮助开发者了解应用/服务的运行状态,更好地调试程序。 +以下文档仅对接口功能进行描述,具体的日志打印要求请参考[OpenHarmony日志打印规范](../../../contribute/OpenHarmony-Log-guide.md)。 + > **说明:** -> > 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 ## 导入模块 @@ -10,184 +12,201 @@ import hilog from '@ohos.hilog'; ``` +## hilog.isLoggable -## hilog.debug - -debug(domain: number, tag: string, format: string, ...args: any[]) : void +isLoggable(domain: number, tag: string, level: LogLevel) : boolean -debug日志输出,打印debug级别日志。 +在打印日志前调用该接口,用于检查指定领域标识、日志标识和级别的日志是否可以打印。 **系统能力:** SystemCapability.HiviewDFX.HiLog **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | -------------- | ---- | ------------------------------------------------------------ | -| domain | number | 是 | 业务领域。范围0x0~0xFFFFF。 | -| tag | string | 是 | 字符串常量,标识调用所在的类或者业务行为。 | -| format | string | 是 | 格式字符串,包含参数类型、隐私标识。未加隐私标识的缺省为隐私参数。 | -| args | any[] | 是 | 与格式字符串里参数类型对应的可变长度参数列表。参数数目、参数类型必须与格式字符串中的标识一一对应。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | --------------------- | ---- | ------------------------------------------------------------ | +| domain | number | 是 | 日志对应的领域标识,范围是0x0~0xFFFF,开发者可根据需要自定义。 | +| tag | string | 是 | 指定日志标识,可以为任意字符串,建议用于标识调用所在的类或者业务行为。 | +| level | [LogLevel](#loglevel) | 是 | 日志级别。 | + +**返回值:** + +| 类型 | 说明 | +| ------- | ------------------------------------------------------------ | +| boolean | 如果返回true,则该领域标识、日志标识和级别的日志可以打印,否则不能打印。 | **示例:** ```js -hilog.debug(0xFF00, "testTag", "%d: %{private}s World %{public}f", 1, "hello", 3.0); +hilog.isLoggable(0x0001, "testTag", hilog.LogLevel.INFO); ``` -**输出:** +## LogLevel -``` -09-08 12:49:35.941 1547 2452 D FF00/testTag: 1: hello World 3.0 -``` +日志级别。 -## hilog.info +**系统能力:** SystemCapability.HiviewDFX.HiLog -info(domain: number, tag: string, format: string, ...args: any[]) : void +| 名称 | 默认值 | 说明 | +| ----- | ------ | ------------------------------------------------------------ | +| DEBUG | 3 | 详细的流程记录,通过该级别的日志可以更详细地分析业务流程和定位分析问题。 | +| INFO | 4 | 用于记录业务关键流程节点,可以还原业务的主要运行过程;
用于记录可预料的非正常情况信息,如无网络信号、登录失败等。
这些日志都应该由该业务内处于支配地位的模块来记录,避免在多个被调用的模块或低级函数中重复记录。 | +| WARN | 5 | 用于记录较为严重的非预期情况,但是对用户影响不大,应用可以自动恢复或通过简单的操作就可以恢复的问题。 | +| ERROR | 6 | 应用发生了错误,该错误会影响功能的正常运行或用户的正常使用,可以恢复但恢复代价较高,如重置数据等。 | +| FATAL | 7 | 重大致命异常,表明应用即将崩溃,故障无法恢复。 | -info日志输出,打印info级别日志。 +## hilog.debug + +debug(domain: number, tag: string, format: string, ...args: any[]) : void + +打印DEBUG级别的日志。 + +DEBUG级别的日志在正式发布版本中默认不被打印,只有在调试版本或打开调试开关的情况下才会打印。 **系统能力:** SystemCapability.HiviewDFX.HiLog **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | -------------- | ---- | ------------------------------------------------------------ | -| domain | number | 是 | 业务领域。范围0x0~0xFFFFF。 | -| tag | string | 是 | 字符串常量,标识调用所在的类或者业务行为。 | -| format | string | 是 | 格式字符串,包含参数类型、隐私标识。未加隐私标识的缺省为隐私参数。 | -| args | any[] | 是 | 与格式字符串里参数类型对应的可变长度参数列表。参数数目、参数类型必须与格式字符串中的标识一一对应。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------------------------------------------------ | +| domain | number | 是 | 日志对应的领域标识,范围是0x0~0xFFFF,开发者可根据需要自定义。 | +| tag | string | 是 | 指定日志标识,可以为任意字符串,建议用于标识调用所在的类或者业务行为。 | +| format | string | 是 | 格式字符串,用于日志的格式化输出。格式字符串中可以设置多个参数,参数需要包含参数类型、隐私标识。
隐私标识分为{public}和{private},缺省为{private}。标识{public}的内容明文输出,标识{private}的内容以\过滤回显。 | +| args | any[] | 是 | 与格式字符串format对应的可变长度参数列表。参数数目、参数类型必须与格式字符串中的标识一一对应。 | **示例:** +输出一条DEBUG信息,格式字符串为`"%{public}s World %{private}d"`。其中变参`%{public}s`为明文显示的字符串;`%{private}d`为隐私的整型数。 + ```js -hilog.info(0xFF00, "testTag", "%d: %{private}s World %{public}f", 1, "hello", 3.0); +hilog.debug(0x0001, "testTag", "%{public}s World %{private}d", "hello", 3); ``` -**输出:** +字符串`"hello"`填入`%{public}s`,整型数`3`填入`%{private}d`,输出日志: ``` -09-08 12:49:35.941 1547 2452 I FF00/testTag: 1: hello World 3.0 +08-05 12:21:47.579 2695-2703/com.example.myapplication D 00001/testTag: hello World ``` -## hilog.warn +## hilog.info -warn(domain: number, tag: string, format: string, ...args: any[]) : void +info(domain: number, tag: string, format: string, ...args: any[]) : void -warn日志输出,打印warn级别日志。 +打印INFO级别的日志。 **系统能力:** SystemCapability.HiviewDFX.HiLog **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | -------------- | ---- | ------------------------------------------------------------ | -| domain | number | 是 | 业务领域。范围0x0~0xFFFFF。 | -| tag | string | 是 | 字符串常量,标识调用所在的类或者业务行为。 | -| format | string | 是 | 格式字符串,包含参数类型、隐私标识。未加隐私标识的缺省为隐私参数。 | -| args | any[] | 是 | 与格式字符串里参数类型对应的可变长度参数列表。参数数目、参数类型必须与格式字符串中的标识一一对应。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------------------------------------------------ | +| domain | number | 是 | 日志对应的领域标识,范围是0x0~0xFFFF,开发者可根据需要自定义。 | +| tag | string | 是 | 指定日志标识,可以为任意字符串,建议用于标识调用所在的类或者业务行为。 | +| format | string | 是 | 格式字符串,用于日志的格式化输出。格式字符串中可以设置多个参数,参数需要包含参数类型、隐私标识。
隐私标识分为{public}和{private},缺省为{private}。标识{public}的内容明文输出,标识{private}的内容以\过滤回显。 | +| args | any[] | 是 | 与格式字符串format对应的可变长度参数列表。参数数目、参数类型必须与格式字符串中的标识一一对应。 | **示例:** +输出一条INFO信息,格式字符串为`"%{public}s World %{private}d"`。其中变参`%{public}s`为明文显示的字符串;`%{private}d`为隐私的整型数。 + ```js -hilog.warn(0xFF00, "testTag", "%d: %{private}s World %{public}f", 1, "hello", 3.0); +hilog.info(0x0001, "testTag", "%{public}s World %{private}d", "hello", 3); ``` -**输出:** +字符串`"hello"`填入`%{public}s`,整型数`3`填入`%{private}d`,输出日志: ``` -09-08 12:49:35.941 1547 2452 W FF00/testTag: 1: hello World 3.0 +08-05 12:21:47.579 2695-2703/com.example.myapplication I 00001/testTag: hello World ``` -## hilog.error +## hilog.warn -error(domain: number, tag: string, format: string, ...args: any[]) : void +warn(domain: number, tag: string, format: string, ...args: any[]) : void -error日志输出,打印error级别日志。 +打印WARN级别的日志。 **系统能力:** SystemCapability.HiviewDFX.HiLog **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | -------------- | ---- | ------------------------------------------------------------ | -| domain | number | 是 | 业务领域。范围0x0~0xFFFFF。 | -| tag | string | 是 | 字符串常量,标识调用所在的类或者业务行为。 | -| format | string | 是 | 格式字符串,包含参数类型、隐私标识。未加隐私标识的缺省为隐私参数。 | -| args | any[] | 是 | 与格式字符串里参数类型对应的可变长度参数列表。参数数目、参数类型必须与格式字符串中的标识一一对应。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------------------------------------------------ | +| domain | number | 是 | 日志对应的领域标识,范围是0x0~0xFFFF,开发者可根据需要自定义。 | +| tag | string | 是 | 指定日志标识,可以为任意字符串,建议用于标识调用所在的类或者业务行为。 | +| format | string | 是 | 格式字符串,用于日志的格式化输出。格式字符串中可以设置多个参数,参数需要包含参数类型、隐私标识。
隐私标识分为{public}和{private},缺省为{private}。标识{public}的内容明文输出,标识{private}的内容以\过滤回显。 | +| args | any[] | 是 | 与格式字符串format对应的可变长度参数列表。参数数目、参数类型必须与格式字符串中的标识一一对应。 | **示例:** +输出一条WARN信息,格式字符串为`"%{public}s World %{private}d"`。其中变参`%{public}s`为明文显示的字符串;`%{private}d`为隐私的整型数。 + ```js -hilog.error(0xFF00, "testTag", "%d: %{private}s World %{public}f", 1, "hello", 3.0); +hilog.warn(0x0001, "testTag", "%{public}s World %{private}d", "hello", 3); ``` -**输出:** +字符串`"hello"`填入`%{public}s`,整型数`3`填入`%{private}d`,输出日志: ``` -09-08 12:49:35.941 1547 2452 E FF00/testTag: 1: hello World 3.0 +08-05 12:21:47.579 2695-2703/com.example.myapplication W 00001/testTag: hello World ``` -## hilog.fatal +## hilog.error -fatal(domain: number, tag: string, format: string, ...args: any[]) : void +error(domain: number, tag: string, format: string, ...args: any[]) : void -fatal日志输出,打印fatal级别日志。 +打印ERROR级别的日志。 **系统能力:** SystemCapability.HiviewDFX.HiLog **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | -------------- | ---- | ------------------------------------------------------------ | -| domain | number | 是 | 业务领域。范围0x0~0xFFFFF。 | -| tag | string | 是 | 字符串常量,标识调用所在的类或者业务行为。 | -| format | string | 是 | 格式字符串,包含参数类型、隐私标识。未加隐私标识的缺省为隐私参数。 | -| args | any[] | 是 | 与格式字符串里参数类型对应的可变长度参数列表。参数数目、参数类型必须与格式字符串中的标识一一对应。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------------------------------------------------ | +| domain | number | 是 | 日志对应的领域标识,范围是0x0~0xFFFF,开发者可根据需要自定义。 | +| tag | string | 是 | 指定日志标识,可以为任意字符串,建议用于标识调用所在的类或者业务行为。 | +| format | string | 是 | 格式字符串,用于日志的格式化输出。格式字符串中可以设置多个参数,参数需要包含参数类型、隐私标识。
隐私标识分为{public}和{private},缺省为{private}。标识{public}的内容明文输出,标识{private}的内容以\过滤回显。 | +| args | any[] | 是 | 与格式字符串format对应的可变长度参数列表。参数数目、参数类型必须与格式字符串中的标识一一对应。 | **示例:** +输出一条ERROR信息,格式字符串为`"%{public}s World %{private}d"`。其中变参`%{public}s`为明文显示的字符串;`%{private}d`为隐私的整型数。 + ```js -hilog.fatal(0xFF00, "testTag", "%d: %{private}s World %{public}f", 1, "hello", 3.0); +hilog.error(0x0001, "testTag", "%{public}s World %{private}d", "hello", 3); ``` -**输出:** +字符串`"hello"`填入`%{public}s`,整型数`3`填入`%{private}d`,输出日志: ``` -09-08 12:49:35.941 1547 2452 F FF00/testTag: 1: hello World 3.0 +08-05 12:21:47.579 2695-2703/com.example.myapplication E 00001/testTag: hello World ``` -## hilog.isLoggable +## hilog.fatal -isLoggable(domain: number, tag: string, level: LogLevel) : boolean +fatal(domain: number, tag: string, format: string, ...args: any[]) : void -检查一个domain、tag和日志级别是否被禁止打印日志。 +打印FATAL级别的日志。 **系统能力:** SystemCapability.HiviewDFX.HiLog **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | --------------------- | ---- | ------------------------------------------ | -| domain | number | 是 | 业务领域。范围0x0~0xFFFFF。 | -| tag | string | 是 | 字符串常量,标识调用所在的类或者业务行为。 | -| level | [LogLevel](#loglevel) | 是 | 日志级别。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------------------------------------------------ | +| domain | number | 是 | 日志对应的领域标识,范围是0x0~0xFFFF,开发者可根据需要自定义。 | +| tag | string | 是 | 指定日志标识,可以为任意字符串,建议用于标识调用所在的类或者业务行为。 | +| format | string | 是 | 格式字符串,用于日志的格式化输出。格式字符串中可以设置多个参数,参数需要包含参数类型、隐私标识。
隐私标识分为{public}和{private},缺省为{private}。标识{public}的内容明文输出,标识{private}的内容以\过滤回显。 | +| args | any[] | 是 | 与格式字符串format对应的可变长度参数列表。参数数目、参数类型必须与格式字符串中的标识一一对应。 | **示例:** +输出一条FATAL信息,格式字符串为`"%{public}s World %{private}d"`。其中变参`%{public}s`为明文显示的字符串;`%{private}d`为隐私的整型数。 + ```js -hilog.isLoggable(0xFF00, "testTag", hilog.DEBUG); +hilog.fatal(0x0001, "testTag", "%{public}s World %{private}d", "hello", 3); ``` -## LogLevel - -用于表示事件类型。 +字符串`"hello"`填入`%{public}s`,整型数`3`填入`%{private}d`,输出日志: -**系统能力:** 以下各项对应的系统能力均为SystemCapability.HiviewDFX.HiLog。 - -| 名称 | 默认值 | 说明 | -| ----- | ------ | ----------- | -| DEBUG | 3 | DEBUG级别。 | -| INFO | 4 | INFO级别。 | -| WARN | 5 | WARN级别。 | -| ERROR | 6 | ERROR级别。 | -| FATAL | 7 | FATAL级别。 | \ No newline at end of file +``` +08-05 12:21:47.579 2695-2703/com.example.myapplication F 00001/testTag: hello World +``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-nfcController.md b/zh-cn/application-dev/reference/apis/js-apis-nfcController.md index a9c7ef7d72a5b0e11a2e4eda9bb9cc028e1f0550..effcf1ae7ac34bba6142895cdc6e80e1f203a247 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-nfcController.md +++ b/zh-cn/application-dev/reference/apis/js-apis-nfcController.md @@ -74,7 +74,7 @@ isNfcOpen(): boolean ## controller.getNfcState -isNfcOpen(): boolean +getNfcState(): boolean 查询NFC是否打开。 @@ -88,13 +88,13 @@ isNfcOpen(): boolean ## controller.on('nfcStateChange') -on(type: "notify", callback: Callback<NfcState>): void +on(type: "nfcStateChange", callback: Callback<NfcState>): void 注册NFC开关状态事件。 **系统能力**:SystemCapability.Communication.NFC -- **参数** +**参数** | **参数名** | **类型** | **必填** | **说明** | | -------- | -------- | -------- | -------- | @@ -111,15 +111,16 @@ off(type: "nfcStateChange", callback?: Callback<NfcState>): void **系统能力**:SystemCapability.Communication.NFC -- **参数** +**参数** | **参数名** | **类型** | **必填** | **说明** | | -------- | -------- | -------- | -------- | | type | string | 是 | 固定填"nfcStateChange"字符串 | | callback | Callback<NfcState> | 否 | 状态改变回调函数。如果callback不填,将“去注册”该事件关联的所有回调函数。 | -- 示例 - ``` +**示例** + + ```js import nfcController from '@ohos.nfcController'; var NFC_STATE_NOTIFY = "nfcStateChange"; diff --git a/zh-cn/application-dev/reference/apis/js-apis-nfcTag.md b/zh-cn/application-dev/reference/apis/js-apis-nfcTag.md index b9a80c9df2ca6556a13ff39d4885d2ccec753598..87fc40e6959e3da7907f5f70ab18f26893e13854 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-nfcTag.md +++ b/zh-cn/application-dev/reference/apis/js-apis-nfcTag.md @@ -17,7 +17,7 @@ import tag from '@ohos.nfc.tag'; getNfcATag(tagInfo: TagInfo): NfcATag -获取NFC A类型Tag对象 +获取NFC A类型Tag对象,通过该对象访问NfcA技术类型的Tag。 **需要权限**:ohos.permission.NFC_TAG @@ -33,7 +33,7 @@ getNfcATag(tagInfo: TagInfo): NfcATag getNfcBTag(tagInfo: TagInfo): NfcBTag -获取NFC B类型Tag对象 +获取NFC B类型Tag对象,通过该对象访问NfcB技术类型的Tag。 **需要权限**:ohos.permission.NFC_TAG @@ -49,7 +49,7 @@ getNfcBTag(tagInfo: TagInfo): NfcBTag getNfcFTag(tagInfo: TagInfo): NfcFTag -获取NFC F类型Tag对象 +获取NFC F类型Tag对象,通过该对象访问NfcF技术类型的Tag。 **需要权限**:ohos.permission.NFC_TAG @@ -65,13 +65,13 @@ getNfcFTag(tagInfo: TagInfo): NfcFTag getNfcVTag(tagInfo: TagInfo): NfcVTag -获取NFC V类型Tag对象 +获取NFC V类型Tag对象,通过该对象访问NfcV技术类型的Tag。 **需要权限**:ohos.permission.NFC_TAG **系统能力**:SystemCapability.Communication.NFC -返回值: +**返回值:** | **类型** | **说明** | | -------- | ---------------- | diff --git a/zh-cn/application-dev/reference/apis/js-apis-notification.md b/zh-cn/application-dev/reference/apis/js-apis-notification.md index ad552f645b57ac742d9915fa91713f7f63147589..2c24a38ab6d4162cb1a061ed954c2e82b00fe7b5 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-notification.md +++ b/zh-cn/application-dev/reference/apis/js-apis-notification.md @@ -185,7 +185,7 @@ Notification.cancel(0, "label", cancelCallback) ## Notification.cancel -cancel(id:number, label?: string): Promise\ +cancel(id: number, label?: string): Promise\ 取消与指定id相匹配的已发布通知,label可以指定也可以不指定(Promise形式)。 @@ -2614,7 +2614,7 @@ Notification.cancelAsBundle(0, representativeBundle, userId, publishCallback); ## Notification.cancelAsBundle9+ -cancelAsBundle(request: NotificationRequest, representativeBundle: string, userId: number): Promise\ +cancelAsBundle(id: number, representativeBundle: string, userId: number): Promise\ 发布代理通知(Promise形式)。 @@ -3212,6 +3212,7 @@ Notification.subscribe(subscriber, subscribeCallback); | lightEnabled | 是 | 是 | boolean | 否 | 是否闪灯。 | | lightColor | 是 | 是 | number | 否 | 通知灯颜色。 | | vibrationValues | 是 | 是 | Array\ | 否 | 通知振动样式。 | +| enabled | 是 | 否 | boolean | 否 | 此通知插槽中的启停状态。 | ## NotificationSorting diff --git a/zh-cn/application-dev/reference/apis/js-apis-permissionrequestresult.md b/zh-cn/application-dev/reference/apis/js-apis-permissionrequestresult.md index c61ec7613803479d2ea83ebe04acdbc0ec73ad9d..5bafa546eaa15a896cb7826891d41ba5eb9174d4 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-permissionrequestresult.md +++ b/zh-cn/application-dev/reference/apis/js-apis-permissionrequestresult.md @@ -6,6 +6,11 @@ 权限请求结果。 +## 导入模块 + +```js +import PermissionRequestResult from '@ohos.application.permissionRequestResult' +``` ## 属性 diff --git a/zh-cn/application-dev/reference/apis/js-apis-processrunninginfo.md b/zh-cn/application-dev/reference/apis/js-apis-processrunninginfo.md index c312c11dd96e2260f981af92574a4baacc48d914..e37475a25ea2c2faea10f15fef6ec1f17f12eda7 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-processrunninginfo.md +++ b/zh-cn/application-dev/reference/apis/js-apis-processrunninginfo.md @@ -6,6 +6,11 @@ 进程运行信息。 +## 导入模块 + +```js +import ProcessRunningInfo from '@ohos.application.processRunningInfo' +``` ## 使用说明 diff --git a/zh-cn/application-dev/reference/apis/js-apis-sms.md b/zh-cn/application-dev/reference/apis/js-apis-sms.md index e776a9365cd5ba3ffd62924c58fc749f42dae57b..c65dc5491b65db2442ff229b1de3630a3aa72c55 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-sms.md +++ b/zh-cn/application-dev/reference/apis/js-apis-sms.md @@ -12,7 +12,7 @@ import sms from '@ohos.telephony.sms'; ## sms.createMessage -createMessage\(pdu: Array, specification: string, callback: AsyncCallback\): void +createMessage\(pdu: Array<number>, specification: string, callback: AsyncCallback\): void 根据协议数据单元(PDU)和指定的短信协议创建短信实例,使用callback方式作为异步方法。 @@ -40,7 +40,7 @@ sms.createMessage(pdu, specification, (err, data) => { ## sms.createMessage -createMessage\(pdu: Array, specification: string\): Promise +createMessage\(pdu: Array<number>, specification: string\): Promise 根据协议数据单元(PDU)和指定的短信协议创建短信实例,使用Promise方式作为异步方法。 @@ -110,7 +110,7 @@ sms.sendMessage(options); ## sms.getDefaultSmsSlotId7+ -getDefaultSmsSlotId\(callback: AsyncCallback\): void +getDefaultSmsSlotId\(callback: AsyncCallback<number>\): void 获取发送短信的默认SIM卡槽ID,使用callback方式作为异步方法。 @@ -133,7 +133,7 @@ sms.getDefaultSmsSlotId((err, data) => { ## sms.getDefaultSmsSlotId7+ -getDefaultSmsSlotId\(\): Promise +getDefaultSmsSlotId\(\): Promise<number> 获取发送短信的默认SIM卡槽ID,使用Promise方式作为异步方法。 @@ -143,7 +143,7 @@ getDefaultSmsSlotId\(\): Promise | 类型 | 说明 | | --------------- | ------------------------------------------------------------ | -| Promise | 以Promise形式返回发送短信的默认SIM卡:
- 0:卡槽1
- 1:卡槽2 | +| Promise<number> | 以Promise形式返回发送短信的默认SIM卡:
- 0:卡槽1
- 1:卡槽2 | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-wantAgent.md b/zh-cn/application-dev/reference/apis/js-apis-wantAgent.md index ddf3b3ec58fb700f1c8ce187952758c7b092f7f5..f4ca3e8db00705f877ed54a4ccfc212f2f7d7c78 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-wantAgent.md +++ b/zh-cn/application-dev/reference/apis/js-apis-wantAgent.md @@ -915,6 +915,53 @@ WantAgent.equal(wantAgent1, wantAgent2).then((data) => { }); ``` +## WantAgent.getOperationType + +getOperationType(agent: WantAgent, callback: AsyncCallback\): void; + +获取WantAgent的操作类型(callback形式)。 + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**参数:** + +| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | +| ---------- | --- | ---- | ------------------------ | ---- | --------------------------------------- | +| agent | 是 | 否 | WantAgent | 是 | WantAgent对象。 | +| callback | 是 | 否 | AsyncCallback\ | 是 | 获取WantAgent的操作类型。 | + +**示例:** + +```js + +``` + +## WantAgent.getOperationType + +getOperationType(agent: WantAgent): Promise\; + +获取WantAgent的操作类型(Promise形式)。 + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**参数:** + +| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | +| ---------- | --- | ---- | --------- | ---- | ------------- | +| agent | 是 | 否 | WantAgent | 是 | WantAgent对象。 | + +**返回值:** + +| 类型 | 说明 | +| ----------------------------------------------------------- | ------------------------------------------------------------ | +| Promise\ | 以Promise形式返回获取WantAgent的操作类型。 | + +**示例:** + +```js + +``` + ## WantAgentInfo 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 64130a267005cd2cabd62bc83de18d848f849d88..afe5736c23ef44ed362e2d840e41813f77e67e3a 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-window.md +++ b/zh-cn/application-dev/reference/apis/js-apis-window.md @@ -58,10 +58,10 @@ import window from '@ohos.window'; | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------------------------------------- | -------- | ---- | ---- | ------------------------------------------------------------ | -| statusBarColor | string | 是 | 是 | 状态栏背景颜色,为16进制RGB或ARGB颜色,例如"\#00FF00"或"\#FF00FF00"。 | +| statusBarColor | string | 是 | 是 | 状态栏背景颜色,为十六进制RGB或ARGB颜色,不区分大小写,例如"\#00FF00"或"\#FF00FF00"。 | | isStatusBarLightIcon7+ | boolean | 否 | 是 | 状态栏图标是否为高亮状态。 | | statusBarContentColor8+ | string | 否 | 是 | 状态栏文字颜色。 | -| navigationBarColor | string | 是 | 是 | 导航栏背景颜色,为16进制RGB或ARGB颜色,例如"\#00FF00"或"\#FF00FF00"。 | +| navigationBarColor | string | 是 | 是 | 导航栏背景颜色,为十六进制RGB或ARGB颜色,不区分大小写,例如"\#00FF00"或"\#FF00FF00"。 | | isNavigationBarLightIcon7+ | boolean | 否 | 否 | 导航栏图标是否为高亮状态。 | | navigationBarContentColor8+ | string | 否 | 是 | 导航栏文字颜色。 | @@ -78,7 +78,7 @@ import window from '@ohos.window'; | type | [WindowType](#windowtype) | 是 | 是 | 当前属性改变的系统栏类型,仅支持类型为导航栏、状态栏的系统栏。 | | isEnable | boolean | 是 | 是 | 当前系统栏是否显示。 | | region | [Rect](#rect) | 是 | 是 | 当前系统栏的位置及大小。 | -| backgroundColor | string | 是 | 是 | 系统栏背景颜色,为16进制RGB或ARGB颜色,例如"\#00FF00"或"\#FF00FF00"。 | +| backgroundColor | string | 是 | 是 | 系统栏背景颜色,为十六进制RGB或ARGB颜色,不区分大小写,例如"\#00FF00"或"\#FF00FF00"。 | | contentColor | string | 是 | 是 | 系统栏文字颜色。 | ## SystemBarTintState8+ @@ -706,11 +706,11 @@ moveTo(x: number, y: number, callback: AsyncCallback<void>): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------- | ---- | --------------------------------------- | -| x | number | 是 | 窗口在x轴方向移动的值,值为正表示右移。 | -| y | number | 是 | 窗口在y轴方向移动的值,值为正表示下移。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | ------------------------------------------------- | +| x | number | 是 | 窗口在x轴方向移动的值,值为正表示右移,单位为px。 | +| y | number | 是 | 窗口在y轴方向移动的值,值为正表示下移,单位为px。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** @@ -735,10 +735,10 @@ moveTo(x: number, y: number): Promise<void> **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ------ | ---- | --------------------------------------- | -| x | number | 是 | 窗口在x轴方向移动的值,值为正表示右移。 | -| y | number | 是 | 窗口在y轴方向移动的值,值为正表示下移。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------------------------------------- | +| x | number | 是 | 窗口在x轴方向移动的值,值为正表示右移,单位为px。 | +| y | number | 是 | 窗口在y轴方向移动的值,值为正表示下移,单位为px。 | **返回值:** @@ -767,11 +767,11 @@ resetSize(width: number, height: number, callback: AsyncCallback<void>): v **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------- | ---- | ---------------- | -| width | number | 是 | 目标窗口的宽度。 | -| height | number | 是 | 目标窗口的高度。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | -------------------------- | +| width | number | 是 | 目标窗口的宽度,单位为px。 | +| height | number | 是 | 目标窗口的高度,单位为px。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** @@ -795,10 +795,10 @@ resetSize(width: number, height: number): Promise<void> **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ------ | ---- | ---------------- | -| width | number | 是 | 目标窗口的宽度。 | -| height | number | 是 | 目标窗口的高度。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | -------------------------- | +| width | number | 是 | 目标窗口的宽度,单位为px。 | +| height | number | 是 | 目标窗口的高度,单位为px。 | **返回值:** @@ -1601,7 +1601,7 @@ setColorSpace(colorSpace:ColorSpace): Promise<void> promise.then((data)=> { console.info('Succeeded in setting window colorspace. Data: ' + JSON.stringify(data)) }).catch((err)=>{ - console.error('Failed to set window colorspacet. Cause: ' + JSON.stringify(err)); + console.error('Failed to set window colorspace. Cause: ' + JSON.stringify(err)); }); ``` @@ -1624,10 +1624,10 @@ getColorSpace(callback: AsyncCallback<ColorSpace>): void ```js windowClass.getColorSpace((err, data) => { if (err.code) { - console.error('Failed to get window color space. Cause:' + JSON.stringify(err)); + console.error('Failed to get window colorspace. Cause:' + JSON.stringify(err)); return; } - console.info('Succeeded in getting window color space. Cause:' + JSON.stringify(data)) + console.info('Succeeded in getting window colorspace. Cause:' + JSON.stringify(data)) }) ``` @@ -1652,7 +1652,7 @@ getColorSpace(): Promise<ColorSpace> promise.then((data)=> { console.info('Succeeded in getting window color space. Cause:' + JSON.stringify(data)) }).catch((err)=>{ - console.error('Failed to set window colorspacet. Cause: ' + JSON.stringify(err)); + console.error('Failed to get window colorspace. Cause: ' + JSON.stringify(err)); }); ``` @@ -1668,7 +1668,7 @@ setBackgroundColor(color: string, callback: AsyncCallback<void>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | ------------------------------------------------------------ | -| color | string | 是 | 需要设置的背景色,为16进制颜色,例如"#00FF00"或"#FF00FF00"。 | +| color | string | 是 | 需要设置的背景色,为十六进制颜色,不区分大小写,例如"#00FF00"或"#FF00FF00"。 | | callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** @@ -1696,7 +1696,7 @@ setBackgroundColor(color: string): Promise<void> | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------------------------------------------------------------ | -| color | string | 是 | 需要设置的背景色,为16进制颜色,例如"#00FF00"或"#FF00FF00"。 | +| color | string | 是 | 需要设置的背景色,为十六进制颜色,不区分大小写,例如"#00FF00"或"#FF00FF00"。 | **返回值:** @@ -1848,7 +1848,7 @@ setKeepScreenOn(isKeepScreenOn: boolean, callback: AsyncCallback<void>): v | 参数名 | 类型 | 必填 | 说明 | | -------------- | ------------------------- | ---- | ------------------------ | -| isKeepScreenOn | boolean | 是 | 是否设置为屏幕常亮状态。 | +| isKeepScreenOn | boolean | 是 | 设置屏幕是否为常亮状态。 | | callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** @@ -1876,7 +1876,7 @@ setKeepScreenOn(isKeepScreenOn: boolean): Promise<void> | 参数名 | 类型 | 必填 | 说明 | | -------------- | ------- | ---- | ------------------------ | -| isKeepScreenOn | boolean | 是 | 是否设置为屏幕常亮状态。 | +| isKeepScreenOn | boolean | 是 | 设置屏幕是否为常亮状态。 | **返回值:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-workScheduler.md b/zh-cn/application-dev/reference/apis/js-apis-workScheduler.md index dc2ca05244d2fdd183942bf724d7fe0ac84680cc..1eeefe3c9a6dc787c90341ff71ce18e5b758c180 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-workScheduler.md +++ b/zh-cn/application-dev/reference/apis/js-apis-workScheduler.md @@ -291,6 +291,8 @@ isLastWorkTimeOut(workId: number): Promise\ | repeatCycleTime | number | 否 | 循环间隔 | | repeatCount | number | 否 | 循环次数 | | isPersisted | boolean | 否 | 是否持久化保存工作 | +| isDeepIdle | boolean | 否 | 是否要求设备进入空闲状态 | +| idleWaitTime | number | 否 | 空闲等待时间 | ## NetworkType 触发工作的网络类型。 diff --git a/zh-cn/application-dev/reference/arkui-js/Readme-CN.md b/zh-cn/application-dev/reference/arkui-js/Readme-CN.md index a9f0f78cdfb53c52bedc134a22ee7ec0b4fa2be1..4ef8ba58b6092774b74d096a3ab36cf09996661c 100644 --- a/zh-cn/application-dev/reference/arkui-js/Readme-CN.md +++ b/zh-cn/application-dev/reference/arkui-js/Readme-CN.md @@ -59,6 +59,7 @@ - [toolbar-item](js-components-basic-toolbar-item.md) - [toggle](js-components-basic-toggle.md) - [web](js-components-basic-web.md) + - [xcomponent](js-components-basic-xcomponent.md) - 媒体组件 - [video](js-components-media-video.md) - 画布组件 diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-basic-xcomponent.md b/zh-cn/application-dev/reference/arkui-js/js-components-basic-xcomponent.md new file mode 100644 index 0000000000000000000000000000000000000000..8a5093a046dfee2df6dac03569a06544b9d23163 --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-js/js-components-basic-xcomponent.md @@ -0,0 +1,72 @@ +# xcomponent + + > **说明:** + > 该组件从API Version 9 开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 + + 用于显示写入了EGL/OpenGLES或媒体数据的组件。 + +## 权限列表 + + 无 + +## 子组件 + + 不支持。 + +## 属性 + +除支持[通用属性](js-components-common-attributes.md)外,还支持如下属性: + +| 名称 | 参数类型 | 必填 | 描述 | +| ----------- | -------- | ---- | ------------------------------------------------------------ | +| id | string | 是 | 组件的唯一标识,支持最大的字符串长度128。 | +| type | string | 是 | 用于指定xcomponent组件类型,可选值为:
-surface:组件内容单独送显,直接合成到屏幕。
-component:组件内容与其他组件合成后统一送显。
| +| libraryname | string | 否 | 应用Native层编译输出动态库名称。 | + +## 样式 + +支持[通用样式](js-components-common-styles.md)。 + +## 事件 + +除支持[通用事件](js-components-common-events.md)外,还支持如下事件: + +| 名称 | 功能描述 | +| ------------------------------- | ------------------------------- | +| onLoad(context?: object) => void | 插件加载完成时回调事件。
context:开发者扩展的xcomponent方法的实例对象,context对象的接口由开发者自定义。 | +| onDestroy() => void | 插件卸载完成时回调事件。 | + +## 方法 + +除支持[通用方法](js-components-common-methods.md)外,还支持如下方法: + +| 名称 | 参数 | 返回值类型 | 描述 | +| ------------------------ | ------------------------------------------------------------ | ---------- | ------------------------------------------------------------ | +| getXComponentSurfaceId | - | string | 获取xcomponent对应Surface的ID,供@ohos接口使用,比如camera相关接口。 | +| setXComponentSurfaceSize | {
surfaceWidth: number,
surfaceHeight: number
} | - | 设置xcomponent持有Surface的宽度和高度。 | +| getXComponentContext | - | object | 获取开发者扩展的xcomponent方法的实例对象。 | + +## 示例 + +提供surface类型xcomponent,支持相机预览等能力。 + + ``` + +
+ camera_display + +
+ ``` + + ``` +// xxx.js +import camera from '@ohos.multimedia.camera'; +export default { + onload() { + var surfaceId = this.$element('xcomponent').getXComponentSurfaceId(); + camera.createPreviewOutput(surfaceId).then((previewOutput) => { + console.log('Promise returned with the PreviewOutput instance'); + }) + } +} + ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md b/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md index daa7a83d5ac49488852dd7a67a62ae66f99ad443..931411f1029df4f7abdc68e53ae7cbf619c8ee7f 100644 --- a/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md +++ b/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md @@ -84,7 +84,7 @@ - [TimePicker](ts-basic-components-timepicker.md) - [Toggle](ts-basic-components-toggle.md) - [Web](ts-basic-components-web.md) - - [Xcomponent](ts-basic-components-xcomponent.md) + - [XComponent](ts-basic-components-xcomponent.md) - 容器组件 - [AlphabetIndexer](ts-container-alphabet-indexer.md) - [Badge](ts-container-badge.md) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-image.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-image.md index 42fb02b76657c2cd0b5328eabd2f0f2d751586b7..c5b2c3e27b872c5b8c2597664e69bdaf6887d273 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-image.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-image.md @@ -1,15 +1,24 @@ # Image -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 +图片组件,支持本地图片和网络图片的渲染展示。 +> **说明:** +> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 -图片组件,用来渲染展示图片。 +## 权限说明 -## 权限列表 +使用网络图片时,需要在config.json(FA模型)或者module.json5(Stage模型)对应的"abilities"中添加网络使用权限ohos.permission.INTERNET。 -ohos.permission.INTERNET(使用网络图片) +``` +"abilities": [ + { + ... + "permissions": ["ohos.permission.INTERNET"], + ... + } +] +``` ## 子组件 @@ -21,61 +30,71 @@ ohos.permission.INTERNET(使用网络图片) Image(src: string | PixelMap | Resource) -- 参数 - | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | - | -------- | -------- | -------- | -------- | -------- | - | src | string\| [PixelMap](../apis/js-apis-image.md#pixelmap7)\| [Resource](../../ui/ts-types.md#resource类型)| 是 | - | 图片的数据源,支持本地图片和网络图片。
\- 支持的图片格式包括png、jpg、bmp、svg和gif。
\- 支持`Base64`字符串。格式`data:image/[png\|jpeg\|bmp\|webp];base64,[base64 data]`, 其中`[base64 data]`为`Base64`字符串数据。
\- 支持`dataability://`路径前缀的字符串,用于访问通过data ability提供的图片路径。 | +通过图片数据源获取图片,用于后续渲染展示。 + +**参数:** +| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | +| -------- | -------- | -------- | -------- | -------- | +| src | string\| [PixelMap](../apis/js-apis-image.md#pixelmap7)\| [Resource](../../ui/ts-types.md#resource类型)| 是 | - | 图片的数据源,支持本地图片和网络图片。
\- 支持的图片格式包括png、jpg、bmp、svg和gif。
\- 支持`Base64`字符串。格式`data:image/[png\|jpeg\|bmp\|webp];base64,[base64 data]`, 其中`[base64 data]`为`Base64`字符串数据。
\- 支持`dataability://`路径前缀的字符串,用于访问通过data ability提供的图片路径。 | ## 属性 +除支持[通用属性](ts-universal-attributes-size.md)外,还支持以下属性: + | 名称 | 参数类型 | 默认值 | 描述 | | -------- | -------- | -------- | -------- | -| alt | string | - | 加载时显示的占位图。支持本地图片和网络路径。 | -| objectFit | ImageFit | Cover | 设置图片的缩放类型。 | -| objectRepeat | [ImageRepeat](ts-appendix-enums.md#imagerepeat枚举说明) | NoRepeat | 设置图片的重复样式。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> - SVG类型图源不支持该属性。 | -| interpolation | ImageInterpolation | None | 设置图片的插值效果,仅针对图片放大插值。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> - SVG类型图源不支持该属性。

> - PixelMap资源不支持该属性。 | -| renderMode | ImageRenderMode | Original | 设置图片渲染的模式。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> - SVG类型图源不支持该属性。 | -| sourceSize | {
width: number,
height: number
} | - | 设置图片解码尺寸,将原始图片解码成指定尺寸的图片,number类型单位为px。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> PixelMap资源不支持该属性。 | +| alt | string \| [Resource](../../ui/ts-types.md#resource类型) | - | 加载时显示的占位图,支持本地图片和网络图片。 | +| objectFit | [ImageFit](#imagefit枚举说明) | ImageFit.Cover | 设置图片的缩放类型。 | +| objectRepeat | [ImageRepeat](ts-appendix-enums.md#imagerepeat) | NoRepeat | 设置图片的重复样式。
> **说明:**
> - svg类型图源不支持该属性。 | +| interpolation | [ImageInterpolation](#imageInterpolation) | ImageInterpolation.None | 设置图片的插值效果,仅针对图片放大插值。
> **说明:**
> - svg类型图源不支持该属性。
> - PixelMap资源不支持该属性。 | +| renderMode | [ImageRenderMode](#imagerendermode) | ImageRenderMode.Original | 设置图片渲染的模式。
> **说明:**
> - svg类型图源不支持该属性。 | +| sourceSize | {
width: number,
height: number
} | - | 设置图片裁剪尺寸,将原始图片解码成pixelMap,指定尺寸的图片,单位为px。
> **说明:**
> PixelMap资源不支持该属性。 | | syncLoad8+ | boolean | false | 设置是否同步加载图片,默认是异步加载。同步加载时阻塞UI线程,不会显示占位图。 | -- ImageFit枚举说明 - | 名称 | 描述 | - | -------- | -------- | - | Cover | 保持宽高比进行缩小或者放大,使得图片两边都大于或等于显示边界。 | - | Contain | 保持宽高比进行缩小或者放大,使得图片完全显示在显示边界内。 | - | Fill | 不保持宽高比进行放大缩小,使得图片填充满显示边界。 | - | None | 保持原有尺寸显示。通常配合objectRepeat属性一起使用。 | - | ScaleDown | 保持宽高比显示,图片缩小或者保持不变。 | - -- ImageInterpolation枚举说明 - | 名称 | 描述 | - | -------- | -------- | - | None | 不使用插值图片数据。 | - | High | 高度使用插值图片数据,可能会影响图片渲染的速度。 | - | Medium | 中度使用插值图片数据。 | - | Low | 低度使用插值图片数据。 | - -- ImageRenderMode枚举说明 - | 名称 | 描述 | - | -------- | -------- | - | Original | 按照原图进行渲染,包括颜色。 | - | Template | 将图像渲染为模板图像,忽略图片的颜色信息。 | +### ImageFit +| 名称 | 描述 | +| -------- | -------- | +| Cover | 保持宽高比进行缩小或者放大,使得图片两边都大于或等于显示边界。 | +| Contain | 保持宽高比进行缩小或者放大,使得图片完全显示在显示边界内。 | +| Fill | 不保持宽高比进行放大缩小,使得图片充满显示边界。 | +| None | 保持原有尺寸显示,通常配合objectRepeat属性一起使用。 | +| ScaleDown | 保持宽高比显示,图片缩小或者保持不变。 | -## 事件 +### ImageInterpolation -| 名称 | 功能描述 | +| 名称 | 描述 | | -------- | -------- | -| onComplete(callback: (event?: { width: number, height: number, componentWidth: number,
 componentHeight: number, loadingStatus: number }) => void) | 图片成功加载时触发该回调,返回成功加载的图源尺寸。 | -| onError(callback: (event?: { componentWidth: number, componentHeight: number }) => void) | 图片加载出现异常时触发该回调。 | -| onFinish(callback: () => void) | 当加载的源文件为带动效的svg图片时,当svg动效播放完成时会触发这个回调,如果动效为无限循环动效,则不会触发这个回调。 | +| None | 不使用插值图片数据。 | +| High | 插值图片数据的使用率高,可能会影响图片渲染的速度。 | +| Medium | 插值图片数据的使用率中。 | +| Low | 插值图片数据的使用率低。 | + +### ImageRenderMode + +| 名称 | 描述 | +| -------- | -------- | +| Original | 按照原图进行渲染,包括颜色。 | +| Template | 将图片渲染为模板图片,忽略图片的颜色信息。 | + +## 事件 +除支持[通用事件](ts-universal-events-click.md)外,还支持以下事件: + +| 名称 | 功能描述 | +| -------- | -------- | +| onComplete(callback: (event?: { width: number, height: number, componentWidth: number,
 componentHeight: number, loadingStatus: number }) => void) | 图片成功加载时触发该回调,返回成功加载的图片尺寸。
- width:图片的宽,单位为像素。
- height:图片的高,单位为像素。
- componentWidth:组件的宽,单位为像素。
- componentHeight:组件的高,单位为像素。
- loadingStatus:图片加载成功的状态。(几为成功)
| +| onError(callback: (event?: { componentWidth: number, componentHeight: number }) => void) | 图片加载出现异常时触发该回调。
- componentWidth:组件的宽,单位为像素。
- componentHeight:组件的高,单位为像素。
| +| onFinish(callback: () => void) | 当加载的源文件为带动效的svg图片时,当svg动效播放完成时会触发这个回调,如果动效为无限循环动效,则不会触发这个回调。 | ## 示例 -``` -// Image1 +### 图片加载 + +加载显示不同类型的图片,并设置图片的缩放类型。 + +```ts @Entry @Component struct ImageExample1 { @@ -141,8 +160,9 @@ struct ImageExample1 { ![zh-cn_image_0000001250492613](figures/zh-cn_image_0000001250492613.gif) -``` -// Image2 +### 设置属性 + +```ts @Entry @Component struct ImageExample2 { @@ -162,12 +182,12 @@ struct ImageExample2 { .border({ width: 1 }).borderStyle(BorderStyle.Dashed) .overlay('Template', { align: Alignment.Bottom, offset: { x: 0, y: 20 } }) } - + Text('alt').fontSize(12).fontColor(0xcccccc).width('96%').height(30) Image('') .alt($r('app.media.Image_none')) .width(100).height(100).border({ width: 1 }).borderStyle(BorderStyle.Dashed) - + Text('sourceSize').fontSize(12).fontColor(0xcccccc).width('96%') Row({ space: 50 }) { Image($r('app.media.img_example')) @@ -187,7 +207,7 @@ struct ImageExample2 { .border({ width: 1 }).borderStyle(BorderStyle.Dashed) .overlay('w:200 h:200', { align: Alignment.Bottom, offset: { x: 0, y: 20 } }) } - + Text('objectRepeat').fontSize(12).fontColor(0xcccccc).width('96%').height(30) Row({ space: 5 }) { Image($r('app.media.ic_health_heart')) @@ -210,17 +230,18 @@ struct ImageExample2 { ![zh-cn_image_0000001205812616](figures/zh-cn_image_0000001205812616.png) -``` -// Image3 +### 事件调用 + +```ts @Entry @Component struct ImageExample3 { @State width: number = 0 @State height: number = 0 - private on: Resource = $r('app.media.wifi_on') - private off: Resource = $r('app.media.wifi_off') - private on2off: Resource = $r('app.media.wifi_on2off') - private off2on: Resource = $r('app.media.wifi_off2on') + private on: Resource = $r('app.media.image_on') + private off: Resource = $r('app.media.image_off') + private on2off: Resource = $r('app.media.image_on2off') + private off2on: Resource = $r('app.media.image_off2on') @State src: Resource = this.on build() { @@ -235,6 +256,7 @@ struct ImageExample3 { }) .objectFit(ImageFit.Cover) .height(180).width(180) + // 图片加载完成后,获取图片尺寸。 .onComplete((msg: { width: number,height: number }) => { this.width = msg.width this.height = msg.height @@ -247,7 +269,7 @@ struct ImageExample3 { offset: { x: 0, y: 20 } }) } - + // 为图片添加点击事件,点击完成后加载特定图片。 Image(this.src) .width(120).height(120) .onClick(() => { 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 bc07a54dc0468749fceea7586b6ad2bd02c4e264..6f80bffcacf25c553d6d11f380a4195131ce3cb2 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 @@ -1,8 +1,9 @@ # TextClock -> ![](public_sys-resources/icon-note.gif) **说明:** 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 +TextClock组件通过文本将当前系统时间显示在设备上。支持不同时区的时间显示,最高精度到秒级。 -TextClock通过文本显示当前系统时间,支持不同时区的时间显示,时间显示最高精度到秒级。 +>**说明:** +>该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 ## 权限列表 @@ -14,36 +15,39 @@ TextClock通过文本显示当前系统时间,支持不同时区的时间显 ## 接口 -TextClock(options?: {timeZoneOffset?: number, contorller?: TextClockController}) +TextClock(options?: { timeZoneOffset?: number, controller?: TextClockController }) -- 参数 +**参数:** - | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | - | -------- | -------- | ---- | ------------------ | ------------------------------------------------------------ | - | timeZoneOffset | number | 否 | 时区偏移量 | 设置时区偏移量。取值范围为[-14, 12],表示东十二区到西十二区,其中负值表示东时区,正值表示西时区,比如东八区为-8;对横跨国际日界线的国家或地区,用-13(UTC+13)和-14(UTC+14)来保证整个国家或者区域处在相同的时间。 | - | contorller | [TextClockContorller](#TextClockController) | 否 | null | 绑定一个控制器,用来控制文本时钟的状态。| +| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | +| -------- | -------- | ---- | ------------------ | ------------------------------------------------------------ | +| timeZoneOffset | number | 否 | 时区偏移量 | 设置时区偏移量。
取值范围为[-14:00, 12:00],表示东十二区到西十二区,其中负值表示东时区,正值表示西时区,比如东八区为-8:00。
对横跨国际日界线的国家或地区,用-13:00(UTC+13)和-14:00(UTC+14)来保证整个国家或者区域处在相同的时间。 | +| contorller | [TextClockContorller](#textclockcontroller) | 否 | null | 绑定一个控制器,用来控制文本时钟的状态。| ## 属性 +除支持[通用属性](ts-universal-attributes-size.md)外,还支持以下属性: + | 名称 | 参数类型 | 默认值 | 描述 | | ------ | -------- | -------- | ------------------------------------------------------------ | -| format | string | 'hhmmss' | 设置显示时间格式,如“yyyy/mm/dd”、“yyyy-mm-dd”等。支持的时间格式化字符串:
  • yyyy(年份)
  • mm(英文月份简写)
  • mmm(英文月份简写)
  • mmmm(英文月份全称)
  • dd(英文星期简写)
  • ddd(英文星期简写)
  • dddd(英文星期全称)
  • HH(24小时制)
  • hh(12小时制)
  • MM/mm(分钟)
  • SS/ss(秒)
| +| format | string | 'hhmmss' | 设置显示时间格式,如“yyyy/mm/dd”、“yyyy-mm-dd”等。
支持的时间格式化字符串:
- yyyy:年份。
- mm:英文月份简写。
- mmm:英文月份简写。
- mmmm:英文月份全称。
- dd:英文星期简写。
- ddd:英文星期简写。
- dddd:英文星期全称。
- HH:24小时制。
- hh:12小时制。
- MM/mm:分钟。
- SS/ss:秒。 | ## 事件 +除支持[通用事件](ts-universal-events-click.md)外,还支持以下事件: + | 名称 | 功能描述 | | -------------------------------------------- | ------------------------------------------------------------ | -| onDateChange(event: (value: number) => void) | 提供时间变化回调,该事件最小回调间隔为秒。
value: Unix Time Stamp,即自1970年1月1日(UTC)起经过的毫秒数。 | +| onDateChange(event: (value: number) => void) | 提供时间变化回调,该事件最小回调间隔为秒。
- value: Unix Time Stamp,即自1970年1月1日(UTC)起经过的毫秒数。 | ## TextClockController -TextClock容器组件的控制器,可以将此对象绑定至TextClock组件,然后通过它控制文本时钟状态的启动与停止。 +TextClock容器组件的控制器,可以将此对象绑定到TextClock组件,再通过它控制文本时钟的启动与停止。 ### 导入对象 -``` +```ts controller: TextClockController = new TextClockController() - ``` ### start @@ -61,7 +65,7 @@ stop() ## 示例 -``` +```ts @Entry @Component struct Second { @@ -70,8 +74,9 @@ struct Second { build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center}) { - Text('current milliseconds is' + this.accumulateTime) + Text('Current milliseconds is ' + this.accumulateTime) .fontSize(20) + // 以12小时制显示东八区的系统时间,精确到秒。 TextClock({timeZoneOffset: -8, controller: this.controller}) .format('hhmmss') .onDateChange((value: number) => { diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-path.md b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-path.md index 2521f303fd32abf7eb675194b2e7271e351fe3e5..f883fbead681e1086960124f68ec3db2e7853366 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-path.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-path.md @@ -1,10 +1,9 @@ # Path -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 - +路径绘制组件,根据绘制路径生成封闭的自定义形状。 -路径绘制组件。 +> **说明:** +> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 ## 权限列表 @@ -16,69 +15,55 @@ 无 - ## 属性 -| 参数名称 | 参数类型 | 默认值 | 必填 | 参数描述 | -| -------- | -------- | -------- | -------- | -------- | -| width | Length | 0 | 否 | 路径所在矩形的宽度。 | -| height | Length | 0 | 否 | 路径所在矩形的高度。 | -| commands | string | '' | 是 | 路径绘制的命令字符串。 | - - -支持的绘制命令如下: - - -- M = moveto - -- L = lineto +除支持[通用属性](ts-universal-attributes-size.md)外,还支持以下属性: -- H = horizontal lineto +| 参数名称 | 参数类型 | 默认值 | 必填 | 参数描述 | +| -------- | --------------------------------------- | ------ | ---- | ------------------------------------------------------------ | +| width | [Length](../../ui/ts-types.md#长度类型) | 0 | 否 | 路径所在矩形画布的宽度。 | +| height | [Length](../../ui/ts-types.md#长度类型) | 0 | 否 | 路径所在矩形画布的高度。 | +| commands | string | '' | 是 | 路径绘制的命令字符串,单位为px。像素单位转换方法请参考[像素单位转换](../../ui/ts-pixel-units.md)。 | -- V = vertical lineto +commands支持的绘制命令如下: -- C = curveto - -- S = smooth curveto - -- Q = quadratic Belzier curve - -- T = smooth quadratic Belzier curveto - -- A = elliptical Arc - -- Z = closepath - - -如 commands('M0 20 L50 50 L50 100 Z')定义了一条路径,开始于位置(0,20),到达位置(50,50)后再到(50,100),最后在(0,20)处关闭路径。 +| 命令 | 名称 | 参数 | 说明 | +| ---- | -------------------------------- | ----------------------------------------------------- | ------------------------------------------------------------ | +| M | moveto | (x y) | 在给定的 (x, y) 坐标处开始一个新的子路径。例如,`M 0 0` 表示将(0, 0)点作为新子路径的起始点。 | +| L | lineto | (x y) | 从当前点到给定的 (x, y) 坐标画一条线,该坐标成为新的当前点。例如,`L 50 50` 表示绘制当前点到(50, 50)点的直线,并将(50, 50)点作为新子路径的起始点。 | +| H | horizontal lineto | x | 从当前点绘制一条水平线,等效于将y坐标指定为0的L命令。例如,`H 50 ` 表示绘制当前点到(50, 0)点的直线,并将(50, 0)点作为新子路径的起始点。 | +| V | vertical lineto | y | 从当前点绘制一条垂直线,等效于将x坐标指定为0的L命令。例如,`V 50 ` 表示绘制当前点到(0, 50)点的直线,并将(0, 50)点作为新子路径的起始点。 | +| C | curveto | (x1 y1 x2 y2 x y) | 使用 (x1, y1) 作为曲线起点的控制点, (x2, y2) 作为曲线终点的控制点,从当前点到 (x, y) 绘制三次贝塞尔曲线。例如,`C100 100 250 100 250 200 ` 表示绘制当前点到(250, 200)点的三次贝塞尔曲线,并将(250, 200)点作为新子路径的起始点。 | +| S | smooth curveto | (x2 y2 x y) | (x2, y2) 作为曲线终点的控制点,绘制从当前点到 (x, y) 绘制三次贝塞尔曲线。若前一个命令是C或S,则起点控制点是上一个命令的终点控制点相对于起点的映射。 例如,`C100 100 250 100 250 200 S400 300 400 200`第二段贝塞尔曲线的起点控制点为(250, 300)。如果没有前一个命令或者前一个命令不是 C或S,则第一个控制点与当前点重合。 | +| Q | quadratic Belzier curve | (x1 y1 x y) | 使用 (x1, y1) 作为控制点,从当前点到 (x, y) 绘制二次贝塞尔曲线。例如,`Q400 50 600 300 ` 表示绘制当前点到(600, 300)点的二次贝塞尔曲线,并将(600, 300)点作为新子路径的起始点。 | +| T | smooth quadratic Belzier curveto | (x y) | 绘制从当前点到 (x, y) 绘制二次贝塞尔曲线。若前一个命令是Q或T,则控制点是上一个命令的终点控制点相对于起点的映射。 例如,`Q400 50 600 300 T1000 300`第二段贝塞尔曲线的控制点为(800, 350)。 如果没有前一个命令或者前一个命令不是 Q或T,则第一个控制点与当前点重合。 | +| A | elliptical Arc | (rx ry x-axis-rotation large-arc-flag sweep-flag x y) | 从当前点到 (x, y) 绘制一条椭圆弧。椭圆的大小和方向由两个半径 (rx, ry) 和x-axis-rotation定义,指示整个椭圆相对于当前坐标系如何旋转(以度为单位)。 large-arc-flag 和 sweep-flag确定弧的绘制方式。 | +| Z | closepath | none | 通过将当前路径连接回当前子路径的初始点来关闭当前子路径。 | +例如: commands('M0 20 L50 50 L50 100 Z')定义了一个三角形,起始于位置(0,20),接着绘制点(0,20)到点(50,50)的直线,再绘制点(50,50)到点(50,100)的直线,最后绘制点(50,100)到(0,20)的直线关闭路径,形成封闭三角形。 ## 示例 -``` +```ts @Entry @Component struct PathExample { build() { Column({ space: 5 }) { Text('Straight line').fontSize(9).fontColor(0xCCCCCC).width('90%') + // 绘制一条长900px,宽3vp的直线。 Path().width(300).height(10).commands('M0 0 L900 0').stroke(Color.Black).strokeWidth(3) Text('Straight line graph').fontSize(9).fontColor(0xCCCCCC).width('90%') Flex({ justifyContent: FlexAlign.SpaceAround }) { - // 先后执行MoveTo(150, 0), LineTo(300, 300), LineTo(0, 300), ClosePath() Path().width(100).height(100).commands('M150 0 L300 300 L0 300 Z') - // 先后执行MoveTo(0, 0), HorizontalLineto(300), VerticalLineto(300), HorizontalLineto(0), ClosePath() Path().width(100).height(100).commands('M0 0 H300 V300 H0 Z') - // 先后执行MoveTo(150, 0), LineTo(0, 150), LineTo(60, 300), LineTo(240, 300), LineTo(300, 150), ClosePath() Path().width(100).height(100).commands('M150 0 L0 150 L60 300 L240 300 L300 150 Z') }.width('100%') Text('Curve graphics').fontSize(9).fontColor(0xCCCCCC).width('90%') Flex({ justifyContent: FlexAlign.SpaceAround }) { - // 先后执行MoveTo(0, 300),(150, 0)(300, 300)两点之间画曲线, ClosePath() Path().width(100).height(100).commands("M0 300 S150 0 300 300 Z") - // 先后执行MoveTo(0, 150),(0, 150)(150, 0)(300, 150)三点之间依次画曲线, LineTo(150, 300),ClosePath() Path().width(100).height(100).commands('M0 150 C0 150 150 0 300 150 L150 300 Z') } }.width('100%').margin({ top: 5 }) @@ -86,4 +71,4 @@ struct PathExample { } ``` -![zh-cn_image_0000001219744193](figures/zh-cn_image_0000001219744193.png) +![zh-cn_image_0000001219744193](figures/zh-cn_image_0000001219744193.png) \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-gesture-settings.md b/zh-cn/application-dev/reference/arkui-ts/ts-gesture-settings.md index 395dfa42cbac26e17527ad19f039c4a90f0c152a..498690dcb00b9e93dc70ccd04d26e5b7ecdf5486 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-gesture-settings.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-gesture-settings.md @@ -79,7 +79,7 @@ struct GestureSettingsExample { TapGesture() .onAction((event: GestureEvent) => { this.value = 'priorityGesture onAction' + '\ncomponent globalPos:(' - + event.target.area.globalPos.x + ',' + event.target.area.globalPos.y + ')\nwidth:' + + event.target.area.globalPosition.x + ',' + event.target.area.globalPosition.y + ')\nwidth:' + event.target.area.width + '\nheight:' + event.target.area.height }), GestureMask.IgnoreInternal ) 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 1d9c61486c3f1cfdfedf13075f30ace03ee3943e..c5da38006bd13fbe276f5b07436c91cf57320611 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 @@ -59,7 +59,7 @@ struct ClickExample { .onClick((event: ClickEvent) => { console.info(this.text = 'Click Point:' + '\n screenX:' + event.screenX + '\n screenY:' + event.screenY + '\n x:' + event.x + '\n y:' + event.y + '\ntarget:' + '\n component globalPos:(' - + event.target.area.globalPos.x + ',' + event.target.area.globalPos.y + ')\n width:' + + event.target.area.globalPosition.x + ',' + event.target.area.globalPosition.y + ')\n width:' + event.target.area.width + '\n height:' + event.target.area.height) }) Text(this.text).padding(15) 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 ca49bfc099d772425df32ccf6d9eb05c77a99e0f..3aa7ea59de2419093c0c27545d8c8b1e044eb3ba 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 @@ -78,7 +78,7 @@ struct TouchExample { } console.info(this.text = 'TouchType:' + this.eventType + '\nDistance between touch point and touch element:\nx: ' + event.touches[0].x + '\n' + 'y: ' + event.touches[0].y + '\ncomponent globalPos:(' - + event.target.area.globalPos.x + ',' + event.target.area.globalPos.y + ')\nwidth:' + + event.target.area.globalPosition.x + ',' + event.target.area.globalPosition.y + ')\nwidth:' + event.target.area.width + '\nheight:' + event.target.area.height) }) Text(this.text) diff --git a/zh-cn/application-dev/security/huks-guidelines.md b/zh-cn/application-dev/security/huks-guidelines.md index 4ef31c5f519db79a8d21b37509a373a0ba6a797b..c5a8655ee077a94caa959da94d513fade25ab0f5 100644 --- a/zh-cn/application-dev/security/huks-guidelines.md +++ b/zh-cn/application-dev/security/huks-guidelines.md @@ -7,16 +7,16 @@ ## 接口说明 -| 接口名 | 描述 | +| 接口名 | 描述 | | ------------------------------------------------------------ | ---------------- | -| function generateKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback) : void; | 生成密钥 | -| function generateKey(keyAlias: string, options: HuksOptions) : Promise; | 生成密钥 | -| function exportKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback) : void; | 导出公钥 | -| function exportKey(keyAlias: string, options: HuksOptions) : Promise; | 导出公钥 | -| function isKeyExist(keyAlias: string, options: HuksOptions, callback: AsyncCallback) : void; | 查询密钥是否存在 | -| function isKeyExist(keyAlias: string, options: HuksOptions) : Promise; | 查询密钥是否存在 | -| function deleteKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback) : void; | 删除密钥 | -| function deleteKey(keyAlias: string, options: HuksOptions) : Promise; | 删除密钥 | +| generateKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback<HuksResult>) : void| 生成密钥 | +| generateKey(keyAlias: string, options: HuksOptions) : Promise<HuksResult>| 生成密钥 | +| exportKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback<HuksResult>) : void| 导出公钥 | +| exportKey(keyAlias: string, options: HuksOptions) : Promise<HuksResult>| 导出公钥 | +| isKeyExist(keyAlias: string, options: HuksOptions, callback: AsyncCallback<boolean>) : void | 查询密钥是否存在 | +| isKeyExist(keyAlias: string, options: HuksOptions) : Promise<boolean> | 查询密钥是否存在 | +| deleteKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback<HuksResult>) : void| 删除密钥 | +| deleteKey(keyAlias: string, options: HuksOptions) : Promise<HuksResult>| 删除密钥 | ## 开发步骤 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 e0d33c93dd14432a0ba8113d5a18a5cf0968a7f5..b7c790de7201fddbf0e6fe68cff729bf06fa9933 100644 --- a/zh-cn/application-dev/ui/ts-component-based-preview.md +++ b/zh-cn/application-dev/ui/ts-component-based-preview.md @@ -11,7 +11,6 @@ ``` -// Display only Hello Component1 on the preview. The content under MyComponent is displayed on the real device. @Entry @Component struct MyComponent { diff --git a/zh-cn/contribute/OpenHarmony-security-design-guide.md b/zh-cn/contribute/OpenHarmony-security-design-guide.md index 2e9da38765fcda1732419a3a570005c7e05b87a8..d0934da52090ec49bd3f752e0dfdbfd88bbe23b1 100644 --- a/zh-cn/contribute/OpenHarmony-security-design-guide.md +++ b/zh-cn/contribute/OpenHarmony-security-design-guide.md @@ -6,17 +6,17 @@ 1-1 为了防止系统和资源被非法访问,除非标准协议约定,所有能对系统进行管理的接口,应具备接入认证机制并缺省启用。 -**说明:**为减少系统攻击面,对于可对系统进行管理(包括配置、升级、调试等)的接口必须要启用认证机制,避免未授权的访问。 +**说明**:为减少系统攻击面,对于可对系统进行管理(包括配置、升级、调试等)的接口必须要启用认证机制,避免未授权的访问。 1-2 只保留运行维护所必需的对外通信连接,关闭不需要连接、端口。 -**说明:**关闭不必要的通信端口,可大大降低安全威胁,是系统安全防护的基础手段。 +**说明**:关闭不必要的通信端口,可大大降低安全威胁,是系统安全防护的基础手段。 ## 2.应用安全 2-1 对于每一个需要授权访问的请求都需核实请求方的会话标识是否合法、请求方是否被授权执行此操作。 -**说明:**避免越权访问。 +**说明**:避免越权访问。 2-2 认证处理过程在客户端实现是不可靠的,可被轻易绕过,因此对用户的最终认证处理过程必须放到服务端进行。 @@ -24,9 +24,9 @@ 3-1 应该使用经过验证的、安全的、公开的加密算法。 -**说明:**算法的安全性不在于算法本身的机密性。 +**说明**:算法的安全性不在于算法本身的机密性。 -**示例:**推荐使用的密码算法: +**示例**:推荐使用的密码算法: 1)分组密码算法:AES(密钥长度在128位及以上) 2)流密码算法:AES(密钥长度在128位及以上)(OFB或CTR模式) 3)非对称加密算法:RSA(推荐3072位) @@ -38,9 +38,9 @@ 3-3 密码算法中使用到的随机数必须是密码学意义上的安全随机数。 -**说明:**使用了不安全的随机数,容易导致密码算法的强度降低甚至算法的失效。 +**说明**:使用了不安全的随机数,容易导致密码算法的强度降低甚至算法的失效。 -**示例:**可使用以下的安全随机数生成接口: +**示例**:可使用以下的安全随机数生成接口: 1) OpenSSL的RAND_bytes或RAND_priv_bytes; 2) OpenSSL FIPS模块中实现的DRBG; 3) JDK的java.security.SecureRandom; @@ -48,37 +48,37 @@ 3-4 默认使用安全的密码算法,关闭或者禁用不安全的密码算法。在选择密码算法库时,应使用通过认证的或业界开源公认的或经评估认可的密码算法库。 -**说明:**随着密码技术的发展以及计算能力的提升,一些密码算法变得不再安全,使用不安全的密码算法,有可能为用户的数据带来风险。同时非专业人员实现的密码算法,在技术上未经业界分析验证,有可能存在未知的缺陷,因此应使用通过认证的或业界开源公认的或经评估认可的密码算法库。 +**说明**:随着密码技术的发展以及计算能力的提升,一些密码算法变得不再安全,使用不安全的密码算法,有可能为用户的数据带来风险。同时非专业人员实现的密码算法,在技术上未经业界分析验证,有可能存在未知的缺陷,因此应使用通过认证的或业界开源公认的或经评估认可的密码算法库。 -**示例:**密码算法相关示例请参考3-1。 +**示例**:密码算法相关示例请参考3-1。 3-5 使用分组密码算法时,应优先选择GCM模式。 3-6 使用RSA算法进行加密操作时,应优先选择OAEP填充方式。 -**说明:**学术界和业界针对RSA的PKCS1填充方式的攻击已经比较成熟,如果不使用OAEP填充替换PKCS1填充,攻击者解密密文的难度将大大降低。 +**说明**:学术界和业界针对RSA的PKCS1填充方式的攻击已经比较成熟,如果不使用OAEP填充替换PKCS1填充,攻击者解密密文的难度将大大降低。 3-7 使用非对称运算保护数据机密性时,避免使用私钥加密敏感数据。 -**说明:**私钥加密无法保护数据的机密性。 +**说明**:私钥加密无法保护数据的机密性。 3-8 使用非对称算法时,加密和签名要使用不同的密钥对。 3-9 在同时需要对数据进行对称加密和数字签名时,使用先签名后加密的方式。检查程序里的密码算法函数调用次序,避免对密文的hash值进行签名(即对密文的hash值进行私钥运算)。 -**说明:**如果对密文签名(即对密文的hash值签名),一旦攻击者可以通过网络嗅探的方式获得密文(也就可以获取密文hash值),就可以任意篡改密文消息的签名。 +**说明**:如果对密文签名(即对密文的hash值签名),一旦攻击者可以通过网络嗅探的方式获得密文(也就可以获取密文hash值),就可以任意篡改密文消息的签名。 3-10 使用DH算法进行密钥协商的双方在接收到对方发送过来的“公钥”时,应判断公钥是不是0,1,p-1,p这样的特殊值并要求重新发起密钥协商。 -**说明:**如果使用DH算法进行密钥协商的双方在接收到的对方发送的“公钥是某些特殊值“,则协商出的密钥也一定是某些已知的值。在这种情况下,攻击者可以尝试最多5个可能的密钥就可以轻易的解密密文。 +**说明**:如果使用DH算法进行密钥协商的双方在接收到的对方发送的“公钥是某些特殊值“,则协商出的密钥也一定是某些已知的值。在这种情况下,攻击者可以尝试最多5个可能的密钥就可以轻易的解密密文。 3-11 在SSL/TLS中协议中,如使用DH/ECDH算法进行密钥协商,出于前向安全考虑,选取包含DHE或ECDHE密钥交换算法的加密套件,避免选取仅包含DH/ECDH的加密套件。 3-12 密码协议中不要使用截短的消息认证码。 -**说明:**密码协议中(如TLS、SSH、IKE等),使用消息认证码(MAC)验证消息的完整性,协议标准有时支持选取截短的消息认证码。此时,消息认证码安全性也因截短而降低,如针对多种密码协议(如TLS、SSH等)的SLOTH攻击就可以利用截短哈希值构造碰撞。 +**说明**:密码协议中(如TLS、SSH、IKE等),使用消息认证码(MAC)验证消息的完整性,协议标准有时支持选取截短的消息认证码。此时,消息认证码安全性也因截短而降低,如针对多种密码协议(如TLS、SSH等)的SLOTH攻击就可以利用截短哈希值构造碰撞。 -**示例:**截短消息认证码的配置举例:SSH协议中配置HMAC-MD5-96、HMAC-SHA1-96、HMAC-SHA2-256-96 +**示例**:截短消息认证码的配置举例:SSH协议中配置HMAC-MD5-96、HMAC-SHA1-96、HMAC-SHA2-256-96 哈希算法的标准输出长度如下,低于标准长度可视为截短: 1)SHA1/HMAC-SHA1,标准输出长度160比特 2)SHA224/HMAC-SHA224,标准输出长度224比特 @@ -90,33 +90,33 @@ 3-13 使用HMAC保护数据完整性时,不能使用hash(key||message)或hash(message||key)的计算结果作为MAC值。 -**说明:**攻击者可以通过在原始明文后面追加任意信息的方式篡改明文,破坏数据的完整性。 +**说明**:攻击者可以通过在原始明文后面追加任意信息的方式篡改明文,破坏数据的完整性。 3-14 同一笔业务中,若既需要加密运算也需要计算MAC时,加密操作和计算MAC操作不能使用同一个对称密钥。 -**说明:**如果加密和MAC密钥相同,一旦密钥泄露,攻击者可以有针对性的篡改机密信息。 +**说明**:如果加密和MAC密钥相同,一旦密钥泄露,攻击者可以有针对性的篡改机密信息。 3-15 加密时避免使用固定的IV(如:硬编码,或固定在配置文件中)。 -**说明:**CBC模式的随机IV值可确保相同的明文、相同的密钥加密出的密文完全不同,如果IV无法确保每次加密都不同,对于CBC模式,攻击者可以轻易的进行密文替换攻击;CBC模式之外的其他分组密码运算模式(如:OFB、CRT等),攻击者可以非常容易的解密密文。 +**说明**:CBC模式的随机IV值可确保相同的明文、相同的密钥加密出的密文完全不同,如果IV无法确保每次加密都不同,对于CBC模式,攻击者可以轻易的进行密文替换攻击;CBC模式之外的其他分组密码运算模式(如:OFB、CRT等),攻击者可以非常容易的解密密文。 3-16 密码协议中避免选择匿名认证、无加密、弱身份认证、弱密钥交换、弱对称加密算法和弱消息认证算法的加密算法套件。 -**说明:**容易造成安全上的薄弱环节从而降低系统的安全性。 +**说明**:容易造成安全上的薄弱环节从而降低系统的安全性。 -**示例:**匿名认证举例:TLS_DH_anon_WITH_3DES_EDE_CBC_SHA、TLS_DH_anon_WITH_AES_256_CBC_SHA +**示例**:匿名认证举例:TLS_DH_anon_WITH_3DES_EDE_CBC_SHA、TLS_DH_anon_WITH_AES_256_CBC_SHA 弱身份认证举例:密钥长度小于2048比特的RSA/DSA密钥 3-17 推荐仅选择使用ECDHE作为密钥交换算法的加密套件。 3-18 用于数据加解密的密钥不能硬编码在代码中,应采用根密钥等加密保护,同时根密钥也需采用适当的安全机制进行保护(如仅对部分密钥组件进行硬编码)。 -**说明:**硬编码密钥容易被逆向分析破解。 +**说明**:硬编码密钥容易被逆向分析破解。 3-19 功能设计中建议支持工作密钥更新方法(密钥更新方式:手动更新、自动更新等),并规定工作密钥更新规则(在线更新、离线更新、更新时间等)。 -**说明:**密钥使用时间越长,密钥被破解的风险也越大;密钥加密的数据量越多,攻击者能够获取到密文的数据机会也越大,而对被同一个密钥加密的多个密文进行密码学分析相对比较容易,导致密钥越容易被破解;如果密钥已经泄露,那么密钥被使用的时间越久,损失越大。 +**说明**:密钥使用时间越长,密钥被破解的风险也越大;密钥加密的数据量越多,攻击者能够获取到密文的数据机会也越大,而对被同一个密钥加密的多个密文进行密码学分析相对比较容易,导致密钥越容易被破解;如果密钥已经泄露,那么密钥被使用的时间越久,损失越大。 -**示例:**当密钥需要更新时,根据密钥生成的规则,重新生成新密钥,同时使用旧密钥解密已加密的数据,并使用新生成的密钥重新加密,同时销毁旧密钥;对于加密数据量很大的场景,可以考虑保留旧密钥,用于解密旧密钥加密的数据,同时使用更新后的密钥加密新数据。 +**示例**:当密钥需要更新时,根据密钥生成的规则,重新生成新密钥,同时使用旧密钥解密已加密的数据,并使用新生成的密钥重新加密,同时销毁旧密钥;对于加密数据量很大的场景,可以考虑保留旧密钥,用于解密旧密钥加密的数据,同时使用更新后的密钥加密新数据。 3-20 密钥材料及密钥组件在保存时须限定其权限(如权限600或400)。 @@ -128,7 +128,7 @@ 4-2 认证凭据不需要还原的场景,应使用PBKDF2等不可逆的算法加密,对于性能敏感且安全性要求不高的场景可使用HMAC(认证凭据,盐值)(注:认证凭据、盐值位置可以互换)。 -**示例:**1、认证凭据使用PBKDF2算法计算口令单向哈希时,迭代次数最低1000次。 +**示例**:1、认证凭据使用PBKDF2算法计算口令单向哈希时,迭代次数最低1000次。 2、盐值Salt为密码学意义上的安全随机数,由系统随机生成,盐值salt至少16字节,并按用户区分。 3、避免使用HASH(用户名||口令)、HMAC(用户名,口令)、HASH(口令 XOR salt)。 @@ -152,40 +152,40 @@ 5-4 应使用合适的安全协议,不安全协议应默认关闭。 -**示例:**安全协议举例:SSHv2/TLS1.2/TLS1.3/IPSec/SFTP/SNMPv3等协议,及其业界最新安全版本。对于流密码算法,建议使用AES的OFB和CTR模式或chacha20流加密算法替换RC4算法。 +**示例**:安全协议举例:SSHv2/TLS1.2/TLS1.3/IPSec/SFTP/SNMPv3等协议,及其业界最新安全版本。对于流密码算法,建议使用AES的OFB和CTR模式或chacha20流加密算法替换RC4算法。 不安全协议举例:TFTP、FTP、Telnet、SSL2.0、SSL3.0、TLS1.0、TLS1.1、SNMP v1/v2和SSHv1.x。 5-5 基于权限最小化原则,系统新建账号默认不授予任何权限,或者默认只指派最小权限(如:只读权限)的角色。 -**说明:**保证当授权机制出现问题或授权机制被绕过时非法用户获得的权限也是最少的。 +**说明**:保证当授权机制出现问题或授权机制被绕过时非法用户获得的权限也是最少的。 ## 6.隐私保护 6-1 收集或使用个人数据前以及将该个人数据发送给第三方之前,应明确提示用户,并获得用户的同意。 -**说明:**增加透明性及用户控制能力,满足GDPR等法律法规要求。 +**说明**:增加透明性及用户控制能力,满足GDPR等法律法规要求。 6-2 正常业务需要的情况下,采集、处理、存储个人数据,应根据实际安全风险提供必要的安全保护机制(如认证、权限控制、日志记录等),以防止个人数据被泄漏、丢失、破坏。 6-3 在说明文档中对产品涉及用户隐私的功能进行描述:该功能处理用户个人数据的目的、范围、处理方式、时限。要求使用该功能时遵从当地适用的法律法规。 -**说明:**增加透明性,满足GDPR等法律法规要求。 +**说明**:增加透明性,满足GDPR等法律法规要求。 6-4 对于所涉及的个人数据,应支持在呈现界面上(如显示界面、文件存储/导出等)进行过滤或匿名化或假名化。 -**说明:**降低个人隐私泄露的风险。 +**说明**:降低个人隐私泄露的风险。 6-5 为避免位置追踪,除了有明确的需求之外,不能出于故障定位等维护目的进行用户精确位置信息定位。 -**说明:**精确位置信息非常敏感,故障定位无需精确定位。 +**说明**:精确位置信息非常敏感,故障定位无需精确定位。 6-6 收集个人数据需基于使用目的所必需,满足最小化原则。用于问题定位的日志中记录个人数据遵循最小化原则。 -**说明:**用于问题定位的日志如果出现个人数据,会引起用户的质疑。应避免打印个人数据,如果必须打印个人数据(如调试目的),必须对个人数据进行匿名化处理。 +**说明**:用于问题定位的日志如果出现个人数据,会引起用户的质疑。应避免打印个人数据,如果必须打印个人数据(如调试目的),必须对个人数据进行匿名化处理。 6-7 涉及个人数据处理的场景,需要提供相关机制,确保数据主体能够查询、更新以及删除所有数据主体的个人数据。 -**说明:**确保数据主体的权利。 +**说明**:确保数据主体的权利。 ## 术语说明 diff --git a/zh-cn/contribute/style-guide/Readme-CN.md b/zh-cn/contribute/style-guide/Readme-CN.md new file mode 100644 index 0000000000000000000000000000000000000000..2a80e2a32cde98f8d5e5898765152df9a8d090dc --- /dev/null +++ b/zh-cn/contribute/style-guide/Readme-CN.md @@ -0,0 +1,6 @@ +# OpenHarmony开发者文档风格指南 + +- [关于本指南](style-guide-overview.md) +- [语言风格](style-guide-language-style.md) +- [文档结构](style-guide-document-structure.md) +- [内容元素](style-guide-content-elements.md) diff --git a/zh-cn/contribute/style-guide/figures/code-block-example.png b/zh-cn/contribute/style-guide/figures/code-block-example.png new file mode 100644 index 0000000000000000000000000000000000000000..a9516e7ffbede5b0d135ee88ecf8881d8475c0ae Binary files /dev/null and b/zh-cn/contribute/style-guide/figures/code-block-example.png differ diff --git a/zh-cn/contribute/style-guide/figures/heading-edit-style.png b/zh-cn/contribute/style-guide/figures/heading-edit-style.png new file mode 100644 index 0000000000000000000000000000000000000000..560254fc93d8b92c2cffa13d8209cd5a5e6c8763 Binary files /dev/null and b/zh-cn/contribute/style-guide/figures/heading-edit-style.png differ diff --git a/zh-cn/contribute/style-guide/figures/heading-preview-style.png b/zh-cn/contribute/style-guide/figures/heading-preview-style.png new file mode 100644 index 0000000000000000000000000000000000000000..5f817d6bf416ff11969dac1eb0a519ba1698a0ee Binary files /dev/null and b/zh-cn/contribute/style-guide/figures/heading-preview-style.png differ diff --git a/zh-cn/contribute/style-guide/figures/recommended-colors.png b/zh-cn/contribute/style-guide/figures/recommended-colors.png new file mode 100644 index 0000000000000000000000000000000000000000..b1b56147bac00df0855e3cc7d63c563c032d7bd6 Binary files /dev/null and b/zh-cn/contribute/style-guide/figures/recommended-colors.png differ diff --git a/zh-cn/contribute/style-guide/figures/screenshot-example.png b/zh-cn/contribute/style-guide/figures/screenshot-example.png new file mode 100644 index 0000000000000000000000000000000000000000..96d7f0f334e1f820f25806c1131e0eaf1f9ca2b0 Binary files /dev/null and b/zh-cn/contribute/style-guide/figures/screenshot-example.png differ diff --git a/zh-cn/contribute/style-guide/style-guide-content-elements.md b/zh-cn/contribute/style-guide/style-guide-content-elements.md new file mode 100644 index 0000000000000000000000000000000000000000..918f34b1464ccdd8059892b5e1b0c1f0a2d2ee0e --- /dev/null +++ b/zh-cn/contribute/style-guide/style-guide-content-elements.md @@ -0,0 +1,377 @@ +# 内容元素 + + +## 项目列表 + +【规则】无序列表统一使用破折号(-)并紧跟一个空格,有序列表统一使用数字并紧跟一个英文句点和一个空格。 + +| **正例** | **反例** | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| \- 无序列表第一项
\- 无序列表第二项
\- 无序列表第三项
1. 有序列表第一项
2. 有序列表第二项
3. 有序列表第三项 | \- 无序列表第一项
\* 无序列表第二项
\+ 无序列表第三项
1) 有序列表第一项
2) 有序列表第二项
3) 有序列表第三项 | + +【规则】列表项采用相似结构、统一句式,例如,全部采用短语或句子。 + +| **正例** | **反例** | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| 播放事件回调类型,支持的事件包括 `'play'|'stop'|'dataLoad'` :
- `play`:完成play()调用,音频开始播放,触发该事件。
- `stop`:完成stop()调用,音频停止播放,触发该事件。
- `dataLoad`:完成音频数据加载后触发该事件,即src属性设置完成后触发该事件。 | 播放事件回调类型,支持的事件包括 `'play'|'stop'|'dataLoad'` :
- `play`:音频开始播放时触发。
- `stop`:音频停止事件。
- `dataLoad`:完成音频数据加载后触发该事件,即src属性设置完成后触发。 | + +【规则】当项目列表项是术语、短语时,句末统一不加标点符号;当项目列表项是句子时,句末统一加句号。 + +| 正例 | 反例 | +| -------- | -------- | +| 支持格式包括:
- video/h263
- audio/mp4a-latm | 无 | + +【建议】一个项目列表的列表项建议为2~9项。 + +【建议】只有一项的列表和前后上下文的内容合并,采用正文样式。 + +【建议】列表的层级不超过2层,包括有序列表和无序列表的组合。 + + +## 表格 + +【规则】表格至少为两行两列。 + +【规则】相同类型的表标题、表头,风格保持一致,采用名词或名词词组的形式。 + +同样对参数进行说明的表,不应出现“参数说明”、“参数解释”、“参数含义”、“参数意义”等不同的表头内容,需要全文保持统一。 + +【规则】同一列信息的表达方式一致,句末的标点符号要保持一致。 + +- 如果表格一列全部为短语,句末不加句号。 + +- 如果表格一列全是句子或同时存在句子和短语,句末统一加句号。 + +【规则】不出现空白的单元格,无内容单元区分“无”和“不涉及”。如果大量的“不涉及”导致表格中重要信息不突出,则采用“-”表示“不涉及”。 + +【规则】Markdown语法不支持合并单元格,遇到对应场景需要进行表格拆分或将行内容直接合并。 + +【规则】表格内容默认使用左对齐。 + + +## 图片 + + +### 图片总体要求 + +【规则】严禁使用无版权图片。如无法确认是否拥有某图片的永久版权,请不要使用,改用自行绘制、拍摄的图片。 + +【规则】图片应清晰展示目标信息,避免使用人工合成或像素低的图片。 + +【规则】图片尺寸不能过大,在页面放大比例为100%的情况下,不能大于一屏。 + +【规则】图片禁止通过URL地址引用,需要取到本地引用。 + +【规则】图片命名规范: + +- 由字母、数字、中划线“-”组成。 + +- 语义化,图片名能体现图片展示内容的核心名词/动词,可从图标题、上下文、展示内容或目的等维度获取,原则上不超过4个英文单词。例如:typical-service-view.png。 + +- 同一文件夹下,图片名不允许重复。 + +【建议】为避免图片过大或过小,影响文档阅读体验,建议的图片宽度为:大图600磅(约800px)、中图360磅(约480px)、小图200磅(约260px)。 + + +### 绘图 + +【建议】字号:中英文正常字号均采用10.5pt(14px)。中文字号下限为9pt(12px),英文字号下限为8pt(11px)。 + +【建议】优先使用灰色、蓝色两套配色,一张图建议不超过3套配色。 + +建议配色如下: + +![建议配色](figures/recommended-colors.png) + + +### 截图 + +【规则】界面截图边缘应完整、清晰。没有明显边界的,应手动添加浅灰色外边框(RGB:217/217/217)。 + +【规则】截图中,不要截取非必要信息,如桌面上的其他图标、工具栏等。 + +【规则】截图中,不能包含敏感信息,如私人邮箱、公网IP地址等。 + +![截图示例](figures/screenshot-example.png) + +【建议】截图中需要突出显示的关键信息,统一使用1px的蓝色(RGB:37/79/247)线框框选。框选时,应使关键信息位于框线中心位置,且框线尽量贴近关键信息边缘。 + + +## 提示与说明 + +【规则】当需要向用户提供区别于正文的重要提示或补充说明信息时,请使用以下信息标识符,以示强调。 + +| 标识符 | 用途/含义 | 典型使用场景举例 | +| -------- | -------- | -------- | +| 说明
(英文为:Note) | 提供帮助提示或有用的参考信息。 | - 支撑开发者做出决策的信息(参数选取原则、系统实现机制补充说明等)
- 可提升开发效率的信息
- 版本差异说明
- 依赖说明
- 相关参考信息 | +| 注意
(英文为:Caution) | 如未按该注意事项操作,可能会导致任务中断或结果异常,但是可恢复。 | - 导致功能异常
- 导致测试失败
- 影响系统开销/系统性能
- 特性约束限制/版本要求
- 影响应用成功安装
- 导致进程攻击
- 导致内存访问错误或内存损坏
- 导致安全类问题(如数据安全/设备安全/帐号安全等)
- 导致稳定性问题
- 导致兼容性问题
- 影响应用分发
- 影响设备安全等级评估
- 影响用户体验(影响可用带宽、服务使用、电池续航、对应用信任度等) | +| 警告
(英文为:Warning) | 如未按该警告内容操作,可能会导致结果异常,且不可恢复。 | - 导致用户数据丢失
- 导致硬件损坏 | + +【规则】使用Markdown的引用语法“>”对提示或补充信息进行描述。 + +> **说明:** + +> 该接口从API Version 7 开始不再维护,建议使用newMethod替代。 + +【规则】提示或补充信息中不能包含表格和图片(图标除外)。 + +【规则】提示或补充信息内容不能过长,建议内容在一个段落范围内。 + +【规则】“注意”及更高级别的提示信息统一放在正文或步骤之前,用来提前警示相关事项,提醒用户避免损失。 + +【规则】禁止滥用“说明”。如果Web页面中一屏幕“说明”的数目超过2个,请考虑将其改为正文信息。 + + +## 链接 + + +### 链接规则 + +当需要参考其他手册内容、本手册中其他章节内容时,可添加到对应内容的链接。 + +【规则】跨文档或跨章节的链接,采用统一表达“请参见xxx”。 + +【规则】使用动词“单击”表示对网页类链接的操作。 + +【建议】对于内容很少(小于100字)但必须参考的内容,建议直接重述该内容;对于参考内容很多且不便重述的内容,添加链接。 + +【建议】一篇文档中应避免出现过多的交叉引用和外部链接。 + + +### 链接样式 + +【规则】将链接URL写入内容,而不是直接在页面中暴露URL地址。 + +- 链接到其他手册、页面内容:\[术语](glossary/glossary.md) + +- 链接到本页面内其他内容段落:\[FAQ](#faq) + +- 链接到其他站点:\[示例](www.example.com) + + | **正例** | **反例** | + | -------- | -------- | + | 请参见\[OpenHarmony开源项目](https://gitee.com/openharmony) | OpenHarmony开源项目请参见https://gitee.com/openharmony | + + +## 术语及缩略语 + +【规则】术语/缩略语名称要同“[OpenHarmony术语表](https://gitee.com/openharmony/docs/blob/master/zh-cn/glossary.md)”保持一致,且全文统一。 + +【规则】对于“[OpenHarmony术语表](https://gitee.com/openharmony/docs/blob/master/zh-cn/glossary.md)”中未涵盖的行业通用术语/缩略语(如IP,MAC等),要同国际、国家、行业标准中的名称保持一致。 + +【规则】禁止随意缩写英文单词,自创缩略语。 + +【规则】除行业通用术语/缩略语外,正文中出现的所有术语/缩略语都需要在术语表中给出解释。 + +【规则】中文文档中,缩略语全称中对应的字母大写。 + +【建议】一篇文档中某缩略语首次出现的位置(标题和表头除外),提供英文全称,可选提供中文全称。 + +【建议】开发板名称、设备名称等不作为术语或缩略语,不在术语表中体现。建议在文档中单独以表格或其他形式介绍。 + + +## 单位符号 + +【规则】用单位符号代替汉字名称。例如:mm代替毫米。 + +【规则】不能在组合单位中同时使用中文符号和单位符号。 + +| **正例** | **反例** | +| -------- | -------- | +| km/h | km/小时 | + +【规则】词头不得孤立使用。 + +| **正例** | **反例** | +| -------- | -------- | +| 64Kbit/s | 64K | + +【规则】常用单位符号请参考下表。 + +| 单位名称 | 符号 | +| -------- | -------- | +| [小]时 | h | +| 分 | min | +| 秒 | s | +| 毫秒 | ms | +| 比特 | bit | +| 千比特 | kbit (表示1000概念时,使用小写k;表示1024概念时,使用大写K) | +| 兆比特 | Mbit | +| 字节 | Byte | +| 千字节 | kB(表示1000概念时,使用小写k;表示1024概念时,使用大写K) | +| 兆字节 | MB | +| 吉字节 | GB | +| 比特/秒 | bit/s (bit/s和bps都正确,但前者更正式) | +| 字节/秒 | Byte/s | +| 千米 | km | +| 米 | m | +| 厘米 | cm | +| 毫米 | mm | +| 微米 | μm | +| 分贝 | dB | +| 摄氏度 | ℃ | +| 华氏度 | ℉ | +| 开[尔文] | K | +| 赫[兹] | Hz | +| 帕[斯卡] | Pa | +| 千克(公斤) | kg | +| 克 | g | + + +## 标点符号 + + 【规则】逗号:不可滥用,不可“一逗到底”。 +| **正例** | **反例** | +| -------- | -------- | +| 帐务计费中心主要负责话单处理和帐务处理。帐务计费中心同计费网关之间有一个话单接口,用于帐务计费中心取用户话单。话单文件采用“\*.txt”的形式。 | 帐务计费中心主要负责话单处理和帐务处理,帐务计费中心同计费网关之间有一个话单接口,用于帐务计费中心取用户话单,话单文件采用“\*.txt”的形式。 | + +【规则】句号: + +- 在正文描述下紧接图或表时,句子说明已完整,以句号结束。 + | **正例** | **反例** | + | -------- | -------- | + | 具体参数说明如表1-2所示。 | 具体参数说明如表1-2所示: | + +- 当一个句子包含在另一个句子中,并且前者属于后者的一部分时,前者句末不加句号。 + | **正例** | **反例** | + | -------- | -------- | + | 在使用xxx(以下简称为x)之前,请先仔细阅读本手册的内容。 | 在使用xxx(以下简称为x。)之前,请先仔细阅读本手册的内容。 | + +- 括号中的内容不属于前一个句子,而是作为一个独立句子并且需要带括号时,句尾加句号。 + +【规则】冒号:不能在一个句子中连续使用冒号,避免导致冒号所提示的范围模糊。 + +| **正例** | **反例** | +| -------- | -------- | +| 正例1:
计费策略:A1 表示计费,A2 表示不计费。
正例2:
计费策略:
- A1:计费
- A2:不计费 | 计费策略:表示计费:A1,表示不计费:A2。 | + +【规则】圆括号: + +- 中文文档中默认使用全角括号(代码块等特殊位置除外)。 + +- 不要在括号中出现太长的说明文字。如果有较长的说明信息,建议作为一个单独的“[说明](#提示与说明)”。 + +【规则】句号、问号、叹号、逗号、顿号、分号和冒号不出现在一行之首。 + +【规则】引号、括号、书名号的前一半不出现在一行之末,后一半不出现在一行之首。 + +【规则】破折号和省略号都占两个字的位置,中间不能断开。 + +【规则】引号:中文文档中默认使用全角引号(代码块等特殊位置除外)。 + +【建议】问号:界面提示、CLI操作提示、语音提示、FAQ中可以使用问号。其他场景限制使用问号。 + +【建议】感叹号:任何场景下,不建议使用感叹号。 + +【建议】省略号:为使文档中描述的信息准确、全面,应尽量少用省略号或“等”。 + +【建议】其他:谨慎使用“√”“×”,在不同国家对这两个符号的理解可能正好相反。 + + +## 字符转义 + +【规则】要显示原本用于格式化Markdown文档的字符,请在字符前添加反斜杠\进行转义,确保显示正常。 + +常见的可用于转义的字符有:“\”、“、”、“\*”、“_”、“{}”、“[]”、“()”、“\#”、“+”、“-”、“.”、“!”、“|”等。 + +| 正例 | 反例 | +| -------- | -------- | +| \\* 文本内容 | \* 文本内容 | + +【规则】对于特殊字符需使用特定的转义符号: + +- “<”使用“&lt”转义。 + +- “>”使用“&gt”转义。 + +- “&”使用“&amp”转义。 + + +## 文件路径 + +文件路径指文件在计算机上的位置。 + +【规则】涉及电脑分区的文件,文件路径需包含明确的根目录。 + +【建议】文件路径尽量使用斜杠“/”来作为文件夹之间的分隔符。 + +【建议】尽量避免文件路径过长的情况。 + + +## 代码与注释 + + +### 行内代码 + +【规则】对于正文描述中涉及代码的内容,比如实际代码中的方法名、参数名或代码文件名等,使用`包裹显示。 + +| 正例 | 反例 | +| -------- | -------- | +| 在`index.js`文件中实现页面跳转。 | 在index.js文件中实现页面跳转。 | + + +### 代码块 + +【规则】对代码示例、命令行使用代码样式。在Markdown中,使用```呈现代码样式,同时指定语言类型。 + +![代码块示例](figures/code-block-example.png) + +【规则】代码块内容应符合对应语言的通用编程规范。 + +【规则】完整举例中的代码块复制后可直接执行,且执行结果与文档描述一致。 + +【规则】如果代码块中没有标识行号,则不添加行号标识。 + +【规则】代码块显示符合缩进要求。 + +【建议】代码块中的关键代码段提供注释说明。 + + +### 注释 + +【规则】适时为代码块添加注释,特别是有解释说明、开发建议或注意事项的位置。恰当的注释可有效提升代码块可读性,帮助开发者快速掌握开发过程。 + +【规则】注释符与代码块语法保持一致,禁止自创注释符。注释符与注释内容间统一添加一个空格。例如:对于JavaScript代码块,注释写法为“// 注释内容”。 + +【规则】当一行注释内容过长时,注意断句切分到下一行呈现。 + + +## IP及MAC地址 + +【规则】IP地址举例只能使用私网IP,禁止使用公网IP(严禁使用实际现网数据)。私网IP地址范围如下。 + +| 组网种类 | 地址范围 | +| -------- | -------- | +| A | 10.0.0.0~10.255.255.255 | +| B | 172.16.0.0~172.31.255.255 | +| C | 192.168.0.0~192.168.255.255 | + +【规则】表示具体组网和路由信息时,IP地址和掩码必须同时出现。 + +- 图片和表格中可以使用如“x.x.x.x/24”的方式,“24”表示掩码长度。 + +- 正文中必须使用255.255.255.0格式表示掩码,如“IP地址为10.10.10.1,子网掩码为255.255.255.252”。 + +【规则】涉及域名示例时,使用开源网址:www.example.com。 + +【规则】涉及MAC地址示例时,在保持格式正确的情况下,使用“X”进行模糊处理。 + +| 正例 | 反例 | +| -------- | -------- | +| 00-01-XX-XX-XX-XX
00:01:XX:XX:XX:XX | 无 | + + +## 个人信息 + +【规则】严禁使用真实的个人信息。 + +【规则】涉及个人电话号码示例时,在保持格式正确的情况下,使用“\*”进行模糊处理。 + +【规则】国际电话号码前添加国家码和地区码,并分别用括号括起,如(86) (755) \*\*\*\*\*\*\*\* [Shenzhen, China]。 + +【规则】涉及个人身份证号、帐号名示例时,在保证格式正确的情况下,使用“\*”进行模糊处理。 + +【规则】涉及邮箱示例时,在保证格式正确的情况下,进行模糊处理,例如:\*\*\*@example.com。 + +【建议】涉及个人姓名示例时,尽可能使用通用名。 + diff --git a/zh-cn/contribute/style-guide/style-guide-document-structure.md b/zh-cn/contribute/style-guide/style-guide-document-structure.md new file mode 100644 index 0000000000000000000000000000000000000000..f03b5d3c0841d31bbda973344b2b5ce2f329698f --- /dev/null +++ b/zh-cn/contribute/style-guide/style-guide-document-structure.md @@ -0,0 +1,140 @@ +# 文档结构 + + +## 标题 + + +### 标题规则 + +【规则】标题应概括反映章节的中心内容,体现章节内容的核心关键词。避免使用“概述Overview”、“简介Introduction”等不带有核心关键词的标题,应补充核心关键词如“内核概述”、“OpenHarmony简介”。 + +【规则】相同级别、相同类型的标题结构保持一致。 + +| **正例** | **反例** | +| -------- | -------- | +| 内核概述
驱动概述
【点评】同为概念类页面,标题风格保持一致。 | 内核介绍
驱动概述 | +| 音频播放开发指导
音频管理开发指导
【点评】同为操作/指导类页面,标题风格保持一致。 | 音频播放开发指导
音频管理开发 | + +【规则】标题中使用的缩略语不必给出全称。标题中出现某一缩略语时,采用以下方式处理: + +- 首次出现该缩略语时,需在随后的正文中给出其全称。 + +- 非首次出现该缩略语时,不需在随后的正文中给出其全称。 + +- 无法判断是否为首次出现该缩略语时,按首次出现该缩略语处理。 + +【规则】标题中不能出现特殊字符。 + +- 这些特殊字符包括:+、-、\*、?、|、^、~、""、'、\、/。由于这些特殊字符带有某些特殊的语义,当这些特殊字符在标题中出现时,会导致标题无法正确显示或无法出现在搜索结果中。 + +- 当标题中无法避免产品名称、功能或特性连用时,请谨慎使用半角的“/”或“&”。 + +【规则】标题结尾不允许使用句号、问号、冒号等标点符号。即使是FAQ的标题也不例外。 + +【规则】标题中不能带上下标。 + +【规则】标题中存在补充说明文字时,统一使用圆括号标识。补充说明文字区分不同维度时,用中文逗号分隔。如:快速入门(标准系统,安装包方式)。 + +【建议】中文标题长度不超过15个汉字,英文不超过25个字符(包括空格)。 + +【建议】概念类/描述类/功能介绍类章节的标题采用名词或名词性词组。 + +| 建议 | 不建议 | +| -------- | -------- | +| OpenHarmony介绍 | 介绍OpenHarmony | + +【建议】任务类章节的标题建议采用动宾结构。 + +| 建议 | 不建议 | +| -------- | -------- | +| 开发首个Hello World | 首个Hello World开发 | + + +### 标题样式 + +【规则】标题包含一级标题、二级标题、三级标题、四级标题……,同一页面内标题层级建议不超过四级。 + +【规则】标题级别必须遵守一级标题 > 二级标题 > 三级标题 > 四级标题的顺序。 + +【规则】不能混用标题的级别,例如:一级标题下面不能直接使用三级标题、四级标题;二级标题下面不能直接使用四级标题。 + + **图1** Markdown中标题编辑样式 +![Markdown中标题编辑样式](figures/heading-edit-style.png) + + **图2** Markdown中标题预览样式 +![Markdown中标题预览样式](figures/heading-preview-style.png) + +## 段落 + +【规则】一个段落只能有一个主题句或中心句。主题句或中心句置于段首。 + +【规则】段落之间要有[清晰的逻辑结构](style-guide-language-style.md#清晰)。 + +【规则】根据内容特点,段落句子使用陈述、肯定或祈使语气,避免使用感叹语气。 + +【建议】一个段落的长度≤7行,最佳段落长度≤4行。 + +【建议】对于技术描述类主题,“字不如表、表不如图”,推荐使用文字、图、表相结合的方式,使内容更易理解。 + +【建议】不出现连续3个以上的纯文字段落。通过图、表等方式避免文字描述的单一性。 + +【建议】段落内容使用正文样式,不要加粗。 + + +## 句子 + +【规则】每个句子只有一个主题。 + +【规则】使用直接陈述,避免双重否定和反问句。 + +【规则】避免“名词 + 名词 + 名词”修饰方式。 + +| **正例** | **反例** | +| -------- | -------- | +| 无 | 配置管理模块
【点评】该短句可能存在如下断句:配置“管理模块”,或“配置管理”模块,根据实际语义优化描述。 | + +【规则】句子的主语应该明确。省略主语时,要保证用户能迅速并正确的确定主语。同一个句子内,避免主语变化。 + +| **正例** | **反例** | +| -------- | -------- | +| 无 | 提示出错
【点评】缺少主语,如“工具提示出错”、“编译子系统提示出错”,在描述时尽量具体、明确。 | + +【规则】使用主谓结构、主谓宾结构的简单句,而非复合句。把复合句改为列表或分拆成简单句和简单复合句。 + +【规则】避免使用长连句,同一个句子中的逗号个数应小于9。 + +【建议】用祈使句表示动作。 + +| 建议 | 不建议 | +| -------- | -------- | +| 在弹出的对话框中,单击“确定”按钮。 | 在弹出的对话框中,请您单击“确定”按钮。 | + +【建议】中文句子长度不超过50个汉字,英文句子长度不超过30个字符。 + +【建议】句子样式默认采用正文样式,不要加粗或添加背景色。 + + +## 目录 + +文档目录分为手册级目录、页面内目录,便于用户高效浏览、获取关键内容。 + +【规则】手册级目录:手册级目录定义以Docs仓库内最小文件夹级别管理。在文件夹内新增页面、修改页面名称、删除页面时,都需同步更新手册级目录。 + +【规则】页面内目录:页面内目录由页面内标题自动生成,写作时请遵循页面内[标题规范及样式](#标题)。 + + +## 文件夹及文件命名 + +【规则】文件夹名:使用文档描述对象的主题英文名称,如:ability、ui等,全小写。 + +【规则】Markdown文件命名规范: + +- 由字母、数字、中划线“-”组成。统一使用“.md”(小写)后缀。 + +- 除Readme.md外,其他文件名原则上全小写。 + +- 语义化,文件名能对文档主题内容进行概括,建议取自该文档的英文标题,如:ability-assistant-guidelines.md。 + +- 原则上不超过4个英文单词。 + +- 同一文件夹下,文件名不允许重复。 diff --git a/zh-cn/contribute/style-guide/style-guide-language-style.md b/zh-cn/contribute/style-guide/style-guide-language-style.md new file mode 100644 index 0000000000000000000000000000000000000000..79fb85b067645c6e135b32c23970c2187fbfde68 --- /dev/null +++ b/zh-cn/contribute/style-guide/style-guide-language-style.md @@ -0,0 +1,197 @@ +# 语言风格 + + +## 人称及语态 + +【规则】使用第二人称。人称代词默认省略,必须出现时,推荐使用“开发者”而不是“你”。 + +| **正例** | **反例** | +| -------- | -------- | +| 使用IDE创建卡片工程。 | 我们使用IDE创建卡片工程。 | + +【建议】尽量使用主动语态。即句子主语是执行动作的人或事物,而不是被操作的事物。 + +| 建议 | 不建议 | +| -------- | -------- | +| 配置参数A,声明支持B功能。 | A参数被配置后,即可支持B功能。 | + + +## 语气及用词 + +【规则】客观陈述内容,口吻友好。 + +| **正例** | **反例** | +| -------- | -------- | +| 确保配置正确。否则,会导致系统工作不正常。 | 你必须保证配置正确。否则后果自负。 | + +【规则】避免使用口语化词语。 + +| **正例** | **反例** | +| -------- | -------- | +| 无 | “不准”、“……的话”、“就可以了”、“做……用”等。 | + +【规则】避免行话。行话只有小部分人员能理解,且难以翻译。 + +| **正例** | **反例** | +| -------- | -------- | +| 非法访问内存空间 | 踩内存 | + +【规则】避免成语和俗语。成语和俗语翻译时很难有效传达其确切含义,没有必要在技术资料中存在。 + +【规则】避免使用可能带有偏见或歧视含义的词汇,包括性别、种族、文化、年龄、技能、职业、宗教、经济水平等方面的偏见或歧视。 + +【规则】避免使用可能会引起操作者负面情绪的词语。 + +| **正例** | **反例** | +| -------- | -------- | +| 无 | “你已被踢出” | + + +## 用户视角 + +【规则】为目标用户(指目标读者,本文简称用户)写作: + +- 明确文档面向的用户(如产品经理、开发者),从而明确用户关注的内容要点,提供且仅提供用户关注的内容。写作中,时刻站在用户视角,思考文章是否覆盖了内容要点、有无冗余。 + +- 针对不同技能水平(如新手、资深)的用户提供支撑信息。 + +- 按照用户认知习惯呈现信息(请参考“[清晰](#清晰)”)。 + +【规则】面向用户场景和用户任务写作: + +- 文档内容应面向用户的真实场景和目标/任务,而非产品功能。 + +- 标题明确体现任务目标。 + +- 对于复杂任务流(超过5步),在操作开始前提供操作流程图或表。 + +- 提供清晰的、step-by-step的操作指导。适当配合界面截图使操作更直观,仅截取关键信息。 + +- 为用户任务就近提供操作支撑信息。 + +- 提供任务全流程所需的支撑信息,例如必要的背景信息、前提条件、准备动作、操作成功的验证方法、常见的故障处理和错误预防信息。 + +- 为所呈现的信息提供必要的理由(例如对用户理解或完成开发任务没有帮助的内部实现原理不需要提供)。 + + +## 完整 + +【规则】避免任务场景缺失。开始写作前,应通过用户与任务分析活动,明确文档要提供哪些任务场景的指导信息。 + +【规则】通过写作模板来保证内容的完整性: + +- OpenHarmony文档遵从结构化、模块化理念,对于每类信息,均根据用户的信息需求提供相应内容模板,即“[OpenHarmony文档写作模板](https://gitee.com/openharmony/docs/tree/master/zh-cn/contribute/template)”。请从中选择最贴近待写作内容的模板,保证知识点覆盖完整。 + +- 写作模板中“必选”的节点,禁止删除。 + +- 写作模板中“可选”的节点,在确定不涉及的情况下,删除即可。 + + +## 具体 + +【规则】用具体的描述代替抽象/晦涩的描述。 + +| **正例** | 反例 | +| -------- | -------- | +| 在编译构建过程中,提示LABEL_VALUE_ERROR错误信息。 | 编译构建失败。 | + +【规则】表示数量或程度时,避免用笼统的“多”“少”“大”,改为具体的、易于感知或衡量的数字。 + +| **正例** | 反例 | +| -------- | -------- | +| 文件大于16MB | 文件超限 | +| 等待30分钟左右 | 等待较长的时间 | +| CPU运行速度提升80% | 性能增强 | + + +## 简洁 + +【规则】使用主谓结构、主谓宾结构的句子,避免添加不必要的修饰成分。 + +【规则】避免使用长连句。同一句子中的逗号数不能超过5个。 + +【规则】禁止使用双重否定。 + +【规则】言简意赅,直接陈述观点。避免无意义的词语,包括表示程度、语气的词。 + +| **正例** | 反例 | +| -------- | -------- | +| 属性不允许重复定义。 | 每个属性最多只允许出现一次。 | +| 绑定服务与通知。 | 将服务与通知绑定就好了。 | + +【规则】根据用户的技能水平,剔除不必要的信息。 + + +## 清晰 + +【规则】确保语言描述清晰,不模糊,不晦涩,易理解(传递一个清楚的意思): + +- 遵循“[具体](#具体)”、“[简洁](#简洁)”的要求。 + +- 确保每个代词都有清晰的指代,能够通过上下文清晰获取其指代对象,便于理解与翻译。 + +- 参数取值原则、原理描述清晰易懂。 + | **正例** | 反例 | + | -------- | -------- | + | 当参数A设置为1时:
- 如果参数B设置为1,表示有下一级跳转,此时页签为方形9宫格。
- 如果参数B设置为0,表示无下一级跳转,此时页签自动变为圆形9宫格。 | 在参数A为1同时参数B为1,如有下一级跳转则页签为方形9宫格,若无下一级跳转则界面页签会自动变为圆形9宫格。 | + +- 避免使用引起歧义的词。 + | **正例** | **反例** | + | -------- | -------- | + | 接通开发板电源。 | 按下开发板电源开关。 | + +- 避免使用含义模糊的词,如表示程度、强调等语气的词。 + | **正例** | **反例** | + | -------- | -------- | + | 无 | - 表示程度的词:较多(more)、较好(better)、基本地(basically)、决定性的(decisively)、最后的  ( finally )、很(very)、可能(may/maybe/could)、大概(probably)、通常( usually )、一般  ( generally )。
- 表示转折的词:当然(of  course)、然而(however)。
- 表示量的词:有些(some)、非常(very)、大量(large  number)、一些(several)、少许(few)。 | + +【规则】确保逻辑清晰: + +- 采用合理的逻辑结构(写作顺序),使章节/段落/步骤/句子顺序符合用户认知习惯。以下常用写作顺序可以独立使用,也可配合使用。 + | **逻辑结构(写作顺序)** | 特征 | 适用的典型信息类型(不限于) | + | -------- | -------- | -------- | + | 先总后分 | 先综述总论点(如特性概述、开发流程概述),再依次展开分论点(子特性详细介绍、开发任务流详细介绍)。
总论点下的分论点做到完全穷尽(不遗漏)、相互独立(无交叠)。 | 功能/场景描述类
开发指导类 | + | 按时间顺序 | 时间、流程或因果上的有先有后。 | 开发指导类 | + | 按空间/结构顺序 | 从上层到下层;从整体到局部。 | 架构描述类
组网描述类 | + | 按重要性顺序 | 从重要到次要;从基础到特殊。 | 开发指导类
问题分析类 | + | 按"情境-冲突-问题-回答"顺序 | 通过追溯问题的起源和发展,引入用户熟悉的情境,然后说明冲突,从而提出最初的问题,最后给出解决方案(也就是即将阐述的主题)。 | 功能/场景描述类 | + +- 对于开发指导类内容,能让用户直观了解具体场景/任务的完整开发流程。 + +- 对于存在分支的步骤,提供明确的选取原则。 + +- 适当使用图、表,使逻辑和表意更直观。 + + +## 一致 + +【规则】用词一致:术语、缩略语、描述同一对象的词汇要全文一致,符合用户的心理预期,禁止使用不同的词汇(包括中英文混用)描述同一事物或操作。 + +OpenHarmony常用词必须遵从下表。 + +| 正例 | 反例 | +| -------- | -------- | +| 登录 | 登陆 | +| 单击 | 点击 | +| 帐户 | 账户 | +| 帐号 | 账号 | +| 图像 | 图象 | +| 计费 | 记费 | +| 阈值 | 阀值 | +| 重写 | 复写 | +| 命令 | 指令 | +| 外形 | 外型 | + +【规则】结构一致:相同文档或者同类信息,保持结构一致,有助于用户对文档结构的把握,方便信息的查找和理解。请优先在“[OpenHarmony文档写作模板](https://gitee.com/openharmony/docs/tree/master/zh-cn/contribute/template)”中选择最贴近待写作内容的模板,遵循模板要求写作。 + +【规则】句式一致:使用一致的句式,不但使技术文档对外表现出一致的风格,也有助于用户在理解内容时,符合已经形成的思维惯性,理解起来更简单。例如统一使用祈使句描述动作。 + +【规则】格式一致:同类元素如[代码块](style-guide-content-elements.md#代码与注释)、[文件路径](style-guide-content-elements.md#文件路径)等,格式保持一致,便于用户理解。 + +【建议】下表给出了另一部分常用词的推荐用法,请参考。 + +| 建议 | 不建议 | +| -------- | -------- | +| 界面 | 页面 | +| 短消息 | 短信 | +| 数据包 | 数据报 | diff --git a/zh-cn/contribute/style-guide/style-guide-overview.md b/zh-cn/contribute/style-guide/style-guide-overview.md new file mode 100644 index 0000000000000000000000000000000000000000..c411b8bf9dedeef16697b12b8260b00e4bc9affc --- /dev/null +++ b/zh-cn/contribute/style-guide/style-guide-overview.md @@ -0,0 +1,21 @@ +# 关于本指南 + + +本指南针对OpenHarmony文档的语言风格、文档结构、内容元素等提供规范要求或参考建议,确保OpenHarmony文档具备一致的风格,同时帮助开发者高效参与文档贡献。 + + +在开始OpenHarmony文档写作前,请先浏览本指南内容,参照相应要求或建议进行写作。 + + +此外,请优先在“[OpenHarmony文档写作模板](https://gitee.com/openharmony/docs/tree/master/zh-cn/contribute/template)”中选择最贴近待写作内容的模板,遵循模板要求进行写作。写作模板提供特定类型文档的针对性写作指引,充分利用写作模板将事半功倍。 + + +本指南持续更新,欢迎提出改进意见。 + + +> **说明:** +> 本指南的内容分为【规则】、【建议】两类: +> +> - 【规则】表示规范要求,必须遵从。 +> +> - 【建议】表示参考建议,可选遵从。 diff --git "a/zh-cn/contribute/\350\256\270\345\217\257\350\257\201\344\270\216\347\211\210\346\235\203\350\247\204\350\214\203.md" "b/zh-cn/contribute/\350\256\270\345\217\257\350\257\201\344\270\216\347\211\210\346\235\203\350\247\204\350\214\203.md" index 2f40d8081d7e442ab2220be7f6fe1a85ea3a4979..8191df923b8cdfbf033670ceb98340f13530c6ff 100644 --- "a/zh-cn/contribute/\350\256\270\345\217\257\350\257\201\344\270\216\347\211\210\346\235\203\350\247\204\350\214\203.md" +++ "b/zh-cn/contribute/\350\256\270\345\217\257\350\257\201\344\270\216\347\211\210\346\235\203\350\247\204\350\214\203.md" @@ -16,8 +16,8 @@ ## LICENSE文件 1. 每个开源仓必须有清晰描述的许可证信息,且许可证必须与OpenHarmony整体许可证规则一致,如用户态开源仓使用Apache License 2.0许可协议,LiteOS内核态开源仓使用BSD 3-clause许可协议。 -2. 每个开源仓的许可证文件必须为纯文本格式,放置于代码仓的根目录,里面包含该许可的全文,并且以”LICENSE“命名,不用带".txt",".md"等后缀。 -3. 如果开源仓的不同源码包含多种许可证,请将主许可证描述在以”LICENSE“命名的文件中,其它许可证请以”LICENSE-许可证类型-备注“命名并放置于仓的根目录或该许可证对应源码的根目录,同时在主许可证中描述各许可证文件位置及其适用的范围与场景。 +2. 每个开源仓的许可证文件必须为纯文本格式,放置于代码仓的根目录,里面包含该许可的全文,并且以“LICENSE”命名,不用带".txt",".md"等后缀。 +3. 如果开源仓的不同源码包含多种许可证,请将主许可证描述在以“LICENSE”命名的文件中,其它许可证请以“LICENSE-许可证类型-备注”命名并放置于仓的根目录或该许可证对应源码的根目录,同时在主许可证中描述各许可证文件位置及其适用的范围与场景。 4. 每个开源仓的许可证文件必须要涵盖该仓下所有文件,确保各许可证的涵盖范围描述准确、精简,并且不要包含不在本仓发布的其它源代码许可等不必要的信息,比如要单独下载的依赖软件的许可不要包含在仓和许可证信息中。 5. 如果开源仓在发布时以二进制形式发布,请确保许可证文件位于其发布格式的常规位置,如发布文件夹或压缩包的顶层目录,对于".jar"格式的文件,许可证可位于META-INF目录。 diff --git "a/zh-cn/contribute/\350\264\241\347\214\256\346\226\207\346\241\243.md" "b/zh-cn/contribute/\350\264\241\347\214\256\346\226\207\346\241\243.md" index 645697e7546c2580d66f50bc33fb0e543fd9d85f..dfcd8a51758adb85cfabaf70b1adc26025f77b68 100755 --- "a/zh-cn/contribute/\350\264\241\347\214\256\346\226\207\346\241\243.md" +++ "b/zh-cn/contribute/\350\264\241\347\214\256\346\226\207\346\241\243.md" @@ -23,15 +23,15 @@ 高质量的问题反馈有助于我们不断完善文档内容和质量,您提供的信息越详尽,对我们问题改进越有帮助。 -1. 在Gitee页面中,“Issue“页签中单击“新建Issue“,在标题栏中描述问题,在编辑框中添加详细问题描述。 -2. 单击“创建“按钮,提交Issue,耐心等待文档团队成员确认您的问题。 +1. 在Gitee页面中,“Issue”页签中单击“新建Issue”,在标题栏中描述问题,在编辑框中添加详细问题描述。 +2. 单击“创建”按钮,提交Issue,耐心等待文档团队成员确认您的问题。 ->![](public_sys-resources/icon-note.gif) **说明:** ->**如何反馈一个高质量的问题?** +>![](public_sys-resources/icon-note.gif) **说明**: +>**如何反馈一个高质量的问题**? > >- 提供问题的清晰描述,描述具体缺失、过时、错误的内容或者需要改进的文字。 >- 解释该问题对用户的影响。 ->- 将给定问题的范围限定在一个具体内容、任务。如果问题牵涉的领域较大,可以将其分解为多个小一点的问题。例如:"文档需要优化" 是一个过于宽泛的问题,而 "XX开发指南缺少对XXX步骤的介绍" 就是一个足够具体的、可操作的问题。 +>- 将给定问题的范围限定在一个具体内容、任务。如果问题牵涉的领域较大,可以将其分解为多个小一点的问题。例如:“文档需要优化” 是一个过于宽泛的问题,而 “XX开发指南缺少对XXX步骤的介绍” 就是一个足够具体的、可操作的问题。 >- 搜索现有问题的列表,查看是否已经有相关的或者类似的问题已被记录。 >- 如果新问题与某其他问题或PR有关联,可以使用其完整 URL 或带 \# 字符的PR编号来引用它。 @@ -42,7 +42,7 @@ 1. 在文档页面右上角单击“编辑“按钮即可跳转到对应的Gitee工程源文件页面。 2. 在Gitee源文件md页面中,在对应内容处完成更改、修复。 3. 修改完成后,可单击“预览“按钮,确认修改结果。 -4. 确认无误后,在“扩展信息框“中填写修改意见和补充信息、Signed-off-by邮箱信息触发DCO校验,单击提交审核。 +4. 确认无误后,在“扩展信息框”中填写修改意见和补充信息、Signed-off-by邮箱信息触发DCO校验,单击提交审核。 例如:Signed-off-by: user.name //与DCO签署邮箱保持一致 diff --git a/zh-cn/device-dev/driver/Readme-CN.md b/zh-cn/device-dev/driver/Readme-CN.md index 0a3ef42249ef30a21979b2d1611b4a8f502b41fd..3ee6c11799a477f3f9b9178545d23d518ba9c006 100755 --- a/zh-cn/device-dev/driver/Readme-CN.md +++ b/zh-cn/device-dev/driver/Readme-CN.md @@ -43,12 +43,15 @@ - [UART](driver-platform-uart-des.md) - [WatchDog](driver-platform-watchdog-des.md) - 外设驱动使用 + - [Audio](driver-peripherals-audio-des.md) + - [Camera](driver-peripherals-camera-des.md) + - [Face_auth](driver-peripherals-face_auth-des.md) - [LCD](driver-peripherals-lcd-des.md) - - [Touchscreen](driver-peripherals-touch-des.md) + - [Light](driver-peripherals-light-des.md) + - [Pin_auth](driver-peripherals-pinauth-des.md) - [Sensor](driver-peripherals-sensor-des.md) - - [WLAN](driver-peripherals-external-des.md) - - [Audio](driver-peripherals-audio-des.md) + - [Touchscreen](driver-peripherals-touch-des.md) - [USB](driver-peripherals-usb-des.md) - - [Camera](driver-peripherals-camera-des.md) + - [User_auth](driver-peripherals-user-auth-des.md) - [Vibrator](driver-peripherals-vibrator-des.md) - - [Light](driver-peripherals-light-des.md) \ No newline at end of file + - [WLAN](driver-peripherals-external-des.md) \ No newline at end of file diff --git "a/zh-cn/device-dev/driver/figures/Vibrator\351\251\261\345\212\250\350\277\220\350\241\214\345\233\276.png" "b/zh-cn/device-dev/driver/figures/Vibrator\351\251\261\345\212\250\350\277\220\350\241\214\345\233\276.png" index d5d5108ea258f52731bfc3b2dee0c5e81b3306ac..52c595d9db32a3023055acea21292772bf2d409a 100755 Binary files "a/zh-cn/device-dev/driver/figures/Vibrator\351\251\261\345\212\250\350\277\220\350\241\214\345\233\276.png" and "b/zh-cn/device-dev/driver/figures/Vibrator\351\251\261\345\212\250\350\277\220\350\241\214\345\233\276.png" differ diff --git a/zh-cn/device-dev/kernel/kernel-small-basic-time.md b/zh-cn/device-dev/kernel/kernel-small-basic-time.md index b378ef425340cd8c5f667c5e8dd42d1bfd58ffa6..9dca8cc0a5b64b3e0991d73247b281c3ed105bf5 100644 --- a/zh-cn/device-dev/kernel/kernel-small-basic-time.md +++ b/zh-cn/device-dev/kernel/kernel-small-basic-time.md @@ -51,7 +51,7 @@ OpenHarmony LiteOS-A内核的时间管理提供下面几种功能,接口详细 前置条件: -- 配置好LOSCFG_BASE_CORE_TICK_PER_SECOND,即系统每秒的Tick数。 +- 配置好LOSCFG_BASE_CORE_TICK_PER_SECOND,即系统每秒的Tick数,范围(0, 1000]。 - 配置好OS_SYS_CLOCK 系统时钟频率,单位:Hz。 diff --git a/zh-cn/device-dev/porting/Readme-CN.md b/zh-cn/device-dev/porting/Readme-CN.md index 1ee96a3cc2883c5190c5868df29bde45aad15a69..80b56ae99e0caa842ec2efea58fab1ba50695da3 100644 --- a/zh-cn/device-dev/porting/Readme-CN.md +++ b/zh-cn/device-dev/porting/Readme-CN.md @@ -59,7 +59,7 @@ repo init -u https://gitee.com/openharmony-sig/manifest.git -b master -m devboar ## 芯片移植案例 -- [轻量系统芯片移植案例](porting-minichip-cases.md) +- 轻量系统芯片移植案例 - [带屏解决方案之恒玄芯片移植案例](porting-bes2600w-on-minisystem-display-demo.md) - [Combo解决方案之ASR芯片移植案例](porting-asr582x-combo-demo.md) - [轻量系统STM32F407芯片移植案例](porting-stm32f407-on-minisystem-eth.md) diff --git a/zh-cn/device-dev/porting/porting-asr582x-combo-demo.md b/zh-cn/device-dev/porting/porting-asr582x-combo-demo.md index dc07773c0db4d7261471af579db3a7b45924b5b1..8e621698eb4c816d7ee12489c1d4089e1d909d23 100755 --- a/zh-cn/device-dev/porting/porting-asr582x-combo-demo.md +++ b/zh-cn/device-dev/porting/porting-asr582x-combo-demo.md @@ -469,13 +469,13 @@ LOSCFG_DRIVERS_HDF_PLATFORM=y 子系统的编译选项入口在相应产品config.json下,以下以`//vendor/asrmicro/wifi_demo/config.json`为例。 -### LWIP组件 +### lwIP组件 -lwip组件的源码在`//third_party/lwip`,Openharmony在kernel中做了定制化,`//kernel/liteos_m/components/net/lwip-2.1`,包括一些接口的重定义,结构体的重定义等。 +lwIP组件的源码在`//third_party/lwip`,OpenHarmony在kernel中做了定制化,`//kernel/liteos_m/components/net/lwip-2.1`,包括一些接口的重定义,结构体的重定义等。 移植过程可参考:[lwIP组件适配](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/porting/porting-chip-board-lwip.md) -本案例在config.json中设置lwip的路径如下: +本案例在config.json中设置lwIP的路径如下: ``` "subsystem": "kernel", @@ -489,7 +489,7 @@ lwip组件的源码在`//third_party/lwip`,Openharmony在kernel中做了定制 ] ``` -另外,需在内核编译配置文件kernel_config/debug.config中,打开编译lwIP的开关 +另外,需在内核编译配置文件kernel_config/debug.config中,打开编译lwIP的开关,如下: ``` LOSCFG_NET_LWIP=y @@ -581,7 +581,7 @@ xts组件的适配,以`//vendor/asrmicro/xts_demo/config.json`为例,需要 dsoftbus组件提供了设备间的发现连接、组网和传输能力,本方案以Wi-Fi设备间的软总线能力为例。 -依赖组件:LWIP组件、security组件、wifi_lite组件。 +依赖组件:lwIP组件、security组件、wifi_lite组件。 前置条件:设备需先连接路由,所有的组网设备需在同一局域网中。 @@ -622,7 +622,7 @@ dsoftbus组件的启动接口可参考`//vendor/asrmicro/wifi_demo/tests/dsoftbu InitSoftBusServer(); ``` -dsoftbus组件的运行需至少预留80KB RAM,如资源不够,可对其它地方进行剪裁,例如LWIP组件,可修改 +dsoftbus组件的运行需至少预留80KB RAM。如资源不够,可对其它地方进行剪裁。例如,可在以下文件修改lwIP组件: `//kernel_liteos_m/blob/master/components/net/lwip-2.1/porting/include/lwip/lwipopts.h`: ``` @@ -670,7 +670,7 @@ void HandleReceiveDeviceId(AuthManager *auth, uint8_t *data) } ``` -在正确配置并编译烧录后,设备使用wifi_open指令连接路由,连接成功后,设备会自动进行组网,如下为组网成功截图: +在正确配置并编译烧录后,设备使用wifi_open指令连接路由,连接成功后,设备会自动进行组网。如下为组网成功截图: ![dsoftbus_join_LNN](figures/asr582x_dsoftbus_join_LNN.png) diff --git a/zh-cn/device-dev/quick-start/Readme-CN.md b/zh-cn/device-dev/quick-start/Readme-CN.md index 93f6cd8a77099718bb886726151c78a1531f0f00..52b8b470b9cedfdfd697e3b117106a0a1dd18a71 100644 --- a/zh-cn/device-dev/quick-start/Readme-CN.md +++ b/zh-cn/device-dev/quick-start/Readme-CN.md @@ -33,7 +33,7 @@ - [烧录](quickstart-lite-steps-hi3861-burn.md) - [联网](quickstart-lite-steps-hi3861-netconfig.md) - [调试验证](quickstart-lite-steps-hi3861-debug.md) - - [运行](quickstart-lite-steps-hi3816-running.md) + - [运行](quickstart-lite-steps-hi3861-running.md) - Hi3516开发板 - [安装Hi3516开发板环境](quickstart-lite-steps-hi3516-setting.md) - [编写“Hello World”程序](quickstart-lite-steps-hi3516-application-framework.md) diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3816-running.md b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-running.md similarity index 100% rename from zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3816-running.md rename to zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-running.md diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861.md b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861.md index 4266d6e5ea673b59b90ac19c571c1c6be397ab4d..3fa241e1f2d8898851898273903e5834b8cdae72 100644 --- a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861.md +++ b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861.md @@ -14,4 +14,5 @@ - **[调试验证](quickstart-lite-steps-hi3861-debug.md)** -- **[运行](quickstart-lite-steps-hi3816-running.md)** \ No newline at end of file +- **[运行](quickstart-lite-steps-hi3861-running.md)** + diff --git a/zh-cn/device-dev/subsystems/Readme-CN.md b/zh-cn/device-dev/subsystems/Readme-CN.md index 575b7c7176e8169cc29860fefb7e1857f11fff36..d8261c7acaf5f437b72d1de3b447ba8a15bf3726 100755 --- a/zh-cn/device-dev/subsystems/Readme-CN.md +++ b/zh-cn/device-dev/subsystems/Readme-CN.md @@ -5,6 +5,7 @@ - [标准系统编译构建指导](subsys-build-standard-large.md) - [构建系统编码规范与最佳实践](subsys-build-gn-coding-style-and-best-practice.md) - [编译构建Kconfig可视化配置指导](subsys-build-gn-kconfig-visual-config-guide.md) + - [HAP编译构建指导](subsys-build-gn-hap-compilation-guide.md) - [分布式远程启动](subsys-remote-start.md) - 图形图像 - [图形图像概述](subsys-graphics-overview.md) @@ -100,4 +101,4 @@ - [bytrace使用指导](subsys-toolchain-bytrace-guide.md) - [hdc_std使用指导](subsys-toolchain-hdc-guide.md) - [hiperf使用指导](subsys-toolchain-hiperf.md) -- [XTS测试用例开发指导](subsys-xts-guide.md) \ No newline at end of file +- [XTS测试用例开发指导](subsys-xts-guide.md) diff --git a/zh-cn/device-dev/subsystems/subsys-build-gn-hap-compilation-guide.md b/zh-cn/device-dev/subsystems/subsys-build-gn-hap-compilation-guide.md new file mode 100644 index 0000000000000000000000000000000000000000..5a01b95c68a77f83c4ca4366e1ed2d0970e61304 --- /dev/null +++ b/zh-cn/device-dev/subsystems/subsys-build-gn-hap-compilation-guide.md @@ -0,0 +1,335 @@ +# HAP编译构建指导 + +## 概述 + +### 基本概念 +| 术语 | 含义 | +| -------------- | ---------------------- | +| HAP | OpenHarmony Ability Package,一个HAP文件包含应用的所有内容,由代码、资源、三方库及应用配置文件组成,其文件后缀名为.hap。 | +| Ability | 应用的重要组成部分,是应用所具备能力的抽象。Ability是系统调度应用的最小单元,是能够完成一个独立功能的组件,一个应用可以包含一个或多个Ability。 | +| FA | Feature Ability,是FA模型的Ability框架下具有UI界面的Ability类型,用于与用户进行交互。Feature Ability唯一对应一种模板,即Page模板(Page Ability)。 | +| PA | Particle Ability,是在FA模型的Ability框架下无界面的Ability,主要为Feature Ability提供服务与支持,例如作为后台服务提供计算能力,或作为数据仓库提供数据访问能力。Particle Ability有三种模板,分别为Service模板(Service Ability)、Data模板(Data Ability)、以及Form模板(Form Ability)。 | +| FA模型 | 两种Ability框架模型结构的其中一种。是Ability框架在API 8及更早版本采用FA模型。FA模型将Ability分为FA(Feature Ability)和PA(Particle Ability)两种类型,其中FA支持Page Ability模板,PA支持Service ability、Data ability、以及Form ability模板。详情可参考[FA模型综述](../../application-dev/ability/fa-brief.md)。 | +| Stage模型 | 两种Ability框架模型结构的其中一种。从API 9开始支持。Stage模型将Ability分为Ability和ExtensionAbility两大类,其中ExtensionAbility又被扩展为ServiceExtensionAbility、FormExtensionAbility、DataShareExtensionAbility等等一系列ExtensionAbility。 | + +### 功能简介 +提供HAP编译构建功能,支持FA模型、Stage模型。 + +## 开发指导 + +### 编译系统提供的模板 +#### ohos_hap + +声明一个HAP目标,该目标会生成一个HAP,最终将会打包到system镜像中。 + +| 支持的变量 | 说明 | +| --------- | ---- | +| hap_profile | HAP的config.json,Stage模型对应module.json。 | +| raw_assets | 原始assets,这些assets会直接拷贝到HAP的assets目录下。 | +| resources | 资源文件,编译后放置在assets/entry/resources目录下 | +| js_assets | js资源,ace编译后放置在assets/js/default目录下。| +| ets_assets | ets资源,ace编译后放置在assets/js/default目录下 | +| deps | 当前目标的依赖 | +| shared_libraries | 当前目标依赖的native库 | +| hap_name | HAP的名字,可选,默认为目标名 | +| final_hap_path | 用户可以制定生成的HAP的位置,可选,final_hap_path中会覆盖hap_name。| +| subsystem_name | HAP从属的子系统名,需要和ohos.build中的名字对应,否则将导致无法安装到system镜像中。| +| part_name | HAP从属的部件名,同subsystem_name。| +| js2abc | 是否需要将该HAP的js代码转换为ARK的字节码。| +| ets2abc | 是否需要将该HAP的ets代码转换为ARK的字节码。| +| certificate_profile | HAP对应的授权文件,用于签名。| +| certificate_file | 证书文件,证书文件和授权文件,应用开发者需要去openharmony官网申请。| +| keystore_path | keystore文件,用于签名。| +| keystore_password | keystore的密码,用于签名。| +| key_alias | key的别名。| +| module_install_name | 安装时的HAP名称。| +| module_install_dir | 安装到system中的位置,默认安装在system/app目录下。| +| js_build_mode | 可选,用于配置HAP是“release”还是“debug”模型编译,默认“release”。| + +#### ohos_app_scope +声明一个HAP的AppScope模块,该目标的app_profile和sources会在编译时拼接到具体的entry内编译,该模板只在Stage模型下使用。 + +| 支持的变量 | 说明 | +| --------- | ---- | +| app_profile | HAP的AppScope中的app.json,只在Stage模型下使用。| +| sources | HAP的AppScope中的资源resources,只在Stage模型下使用。| + +#### ohos_js_assets +js或ets代码,ace编译后放置在assets/js/default目录下,stage模型根据代码分别放置到js或ets目录。 + +| 支持的变量 | 说明 | +| --------- | ---- | +| hap_profile | HAP的config.json,Stage模型对应module.json。| +| source_dir | js或ets代码路径,兼容FA模型的单ability配置到ability目录。| +| ets2abc | 当前为ets代码,主要用于卡片配置,其他应用可不配,使用ohos_hap中的配置。| +| js2abc | 当前为js代码,主要用于卡片配置,其他应用可不配,使用ohos_hap中的配置。| + +#### ohos_assets +原始assets,这些assets会直接拷贝到HAP的assets目录下。 + +| 支持的变量 | 说明 | +|---------- | ---- | +| sources | 原始assets的路径。| + +#### ohos_resources +资源文件,FA模型编译后放置在assets/entry/resources目录下,Stage模型编译后放置在resources目录下。 + +| 支持的变量 | 说明 | +| --------- | ---- | +| hap_profile | HAP的config.json,Stage模型对应module.json。| +| sources | 资源文件路径。| +| deps | 当前目标的依赖。Stage模型需要配置对ohos_app_scope目标的依赖。| + +### 操作步骤 + +1. 将开发完成的应用example放到applications/standard/目录下。 + +2. 配置gn脚本applications/standard/example/BUILD.gn,FA模型简单示例如下(更多BUILD.gn配置见[gn脚本配置示例](#gn脚本配置示例)): + ``` + import("//build/ohos.gni") # 引用ohos.gni + + ohos_hap("example") { + hap_profile = "./src/main/config.json" # config.json + js_assets = ["./src/main/js/default"] + raw_assets = ["./raw_assets"] + resources = ["./src/main/resources"] + shared_libraries = [ + "//third_party/libpng:libpng", # native库 + ] + certificate_profile = "../signature/systemui.p7b" # Cer文件 + hap_name = "SystemUI-NavigationBar" # 名字 + part_name = "prebuilt_hap" + subsystem_name = "applications" + } + ``` + +3. 修改applications/standard/hap/ohos.build,示例如下: + ``` + { + "subsystem": "applications", + "parts": { + "prebuilt_hap": { + "module_list": [ + ... + "//applications/standard/example:example" # 添加编译目标 + ] + } + } + } + ``` + +4. 编译命令: + ``` + # 全量编译 + ./build.sh --product-name {product_name} + + # 单独编译HAP + ./build.sh --product-name {product_name} --build-target applications/standard/example:example + ``` + +5. 编译产物,FA模型简单例子HAP解压视图如下: + ``` + Length Date Time Name + --------- ---------- ----- ---- + 1439 2009-01-01 00:00 assets/raw_assets -----> raw_assets + 354 2009-01-01 00:00 assets/entry/resources.index ------> resources + 1 2009-01-01 00:00 assets/entry/resources/base/media/attributes.key ------> resources + 1 2009-01-01 00:00 assets/entry/resources/base/media/constants.key ------> resources + 1 2009-01-01 00:00 assets/entry/resources/base/media/contents.key ------> resources + 6790 2009-01-01 00:00 assets/entry/resources/base/media/icon.png ------> resources + 1 2009-01-01 00:00 assets/entry/resources/base/media/nodes.key ------> resources + 11170 2009-01-01 00:00 assets/js/default/app.js ------> js_assets + 48 2009-01-01 00:00 assets/js/default/i18n/en-US.json ------> js_assets + 50 2009-01-01 00:00 assets/js/default/i18n/zh-CN.json ------> js_assets + 224 2009-01-01 00:00 assets/js/default/manifest.json ------> js_assets + 41481 2009-01-01 00:00 assets/js/default/pages/index/index.js ------> js_assets + 909 2009-01-01 00:00 config.json ------> hap_profile + 266248 2009-01-01 00:00 libs/libpng.z.so ------> shared_libraries + ``` + +### gn脚本配置示例 +- FA模型多ability示例 + + ``` + import("//build/ohos.gni") + + ohos_hap("dataability") { + hap_profile = "entry/src/main/config.json" + deps = [ + ":dataability_js_assets", + ":dataability_resources", + ] + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "dataability" + part_name = "prebuilt_hap" + subsystem_name = "applications" + } + + ohos_js_assets("dataability_js_assets") { + ets2abc = true + source_dir = "entry/src/main/ets" + hap_profile = "entry/src/main/config.json" + } + + ohos_resources("dataability_resources") { + sources = [ + "entry/src/main/resources", + ] + hap_profile = "entry/src/main/config.json" + } + + ``` + +- FA模型Js卡片示例 + + ``` + import("//build/ohos.gni") + + ohos_hap("FormOfFaJs") { + hap_profile = "entry/src/main/config.json" + deps = [ + ":FormOfFaJs_js_assets", + ":FormOfFaJs_resources", + ] + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "FormOfFaJs" + part_name = "prebuilt_hap" + subsystem_name = "applications" + } + + ohos_js_assets("FormOfFaJs_js_assets") { + hap_profile = "entry/src/main/config.json" + js2abc = true + source_dir = "entry/src/main/js" + } + + ohos_resources("FormOfFaJs_resources") { + sources = [ + "entry/src/main/resources", + ] + hap_profile = "entry/src/main/config.json" + } + ``` + +- FA模型Ets卡片示例 + + ``` + import("//build/ohos.gni") + + ohos_hap("FormOfFaEts") { + hap_profile = "entry/src/main/config.json" + deps = [ + ":FormOfFaEts_js_assets", + ":FormOfFaEts_form_js_assets", + ":FormOfFaEts_resources", + ] + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "FormOfFaEts" + part_name = "prebuilt_hap" + subsystem_name = "applications" + } + + ohos_js_assets("FormOfFaEts_js_assets") { + hap_profile = "entry/src/main/config.json" + ets2abc = true + source_dir = "entry/src/main/ets" + } + + ohos_js_assets("FormOfFaEts_form_js_assets") { + hap_profile = "entry/src/main/config.json" + js2abc = true + source_dir = "entry/src/main/js" + } + + ohos_resources("FormOfFaEts_resources") { + sources = [ + "entry/src/main/resources", + ] + hap_profile = "entry/src/main/config.json" + } + ``` + +- Stage模型简单示例 + + ``` + import("//build/ohos.gni") + + ohos_hap("actmoduletest") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actmoduletest_js_assets", + ":actmoduletest_resources", + ] + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "actmoduletest" + part_name = "prebuilt_hap" + subsystem_name = "applications" + } + + ohos_app_scope("actmoduletest_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] + } + + ohos_js_assets("actmoduletest_js_assets") { + ets2abc = true + source_dir = "entry/src/main/ets" + } + + ohos_resources("actmoduletest_resources") { + sources = [ + "entry/src/main/resources", + ] + deps = [ + ":actmoduletest_app_profile", + ] + hap_profile = "entry/src/main/module.json" + } + ``` + +- Stage模型卡片示例 + + ``` + import("//build/ohos.gni") + + ohos_hap("FormOfStageEts") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":FormOfStageEts_js_assets", + ":FormOfStageEts_form_js_assets", + ":FormOfStageEts_resources", + ] + js_build_mode = "debug" # 默认release + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "FormOfStageEts" + part_name = "prebuilt_hap" + subsystem_name = "applications" + } + + ohos_js_assets("FormOfStageEts_js_assets") { + hap_profile = "entry/src/main/module.json" + ets2abc = true + source_dir = "entry/src/main/ets" + } + + ohos_js_assets("FormOfStageEts_form_js_assets") { + hap_profile = "entry/src/main/module.json" + js2abc = true + source_dir = "entry/src/main/js" + } + + ohos_app_scope("FormOfStageEts_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] + } + + ohos_resources("FormOfStageEts_resources") { + sources = [ + "entry/src/main/resources", + ] + deps = [ + ":FormOfStageEts_app_profile", + ] + hap_profile = "entry/src/main/module.json" + } + ``` diff --git a/zh-cn/device-dev/website.md b/zh-cn/device-dev/website.md index 0ed58370a2682e3ccd84b48eb4279fbe866a098d..a1803548984b21c701d3804087960d6e8e73ff85 100644 --- a/zh-cn/device-dev/website.md +++ b/zh-cn/device-dev/website.md @@ -35,7 +35,7 @@ - [烧录](quick-start/quickstart-lite-steps-hi3861-burn.md) - [联网](quick-start/quickstart-lite-steps-hi3861-netconfig.md) - [调试验证](quick-start/quickstart-lite-steps-hi3861-debug.md) - - [运行](quick-start/quickstart-lite-steps-hi3816-running.md) + - [运行](quick-start/quickstart-lite-steps-hi3861-running.md) - Hi3516开发板 - [安装Hi3516开发板环境](quick-start/quickstart-lite-steps-hi3516-setting.md) - [编写“Hello World”程序](quick-start/quickstart-lite-steps-hi3516-application-framework.md) @@ -342,50 +342,53 @@ - [配置管理](driver/driver-hdf-manage.md) - [HDF开发实例](driver/driver-hdf-sample.md) - 平台驱动开发 - - [ADC](driver-platform-adc-develop.md) - - [DAC](driver-platform-dac-develop.md) - - [GPIO](driver-platform-gpio-develop.md) - - [HDMI](driver-platform-hdmi-develop.md) - - [I2C](driver-platform-i2c-develop.md) - - [I3C](driver-platform-i3c-develop.md) - - [MIPI CSI](driver-platform-mipicsi-develop.md) - - [MIPI DSI](driver-platform-mipidsi-develop.md) - - [MMC](driver-platform-mmc-develop.md) - - [PIN](driver-platform-pin-develop.md) - - [PWM](driver-platform-pwm-develop.md) - - [Regulator](driver-platform-regulator-develop.md) - - [RTC](driver-platform-rtc-develop.md) - - [SDIO](driver-platform-sdio-develop.md) - - [SPI](driver-platform-spi-develop.md) - - [UART](driver-platform-uart-develop.md) - - [WatchDog](driver-platform-watchdog-develop.md) + - [ADC](driver/driver-platform-adc-develop.md) + - [DAC](driver/driver-platform-dac-develop.md) + - [GPIO](driver/driver-platform-gpio-develop.md) + - [HDMI](driver/driver-platform-hdmi-develop.md) + - [I2C](driver/driver-platform-i2c-develop.md) + - [I3C](driver/driver-platform-i3c-develop.md) + - [MIPI CSI](driver/driver-platform-mipicsi-develop.md) + - [MIPI DSI](driver/driver-platform-mipidsi-develop.md) + - [MMC](driver/driver-platform-mmc-develop.md) + - [PIN](driver/driver-platform-pin-develop.md) + - [PWM](driver/driver-platform-pwm-develop.md) + - [Regulator](driver/driver-platform-regulator-develop.md) + - [RTC](driver/driver-platform-rtc-develop.md) + - [SDIO](driver/driver-platform-sdio-develop.md) + - [SPI](driver/driver-platform-spi-develop.md) + - [UART](driver/driver-platform-uart-develop.md) + - [WatchDog](driver/driver-platform-watchdog-develop.md) - 平台驱动使用 - - [ADC](driver-platform-adc-des.md) - - [DAC](driver-platform-dac-des.md) - - [GPIO](driver-platform-gpio-des.md) - - [HDMI](driver-platform-hdmi-des.md) - - [I2C](driver-platform-i2c-des.md) - - [I3C](driver-platform-i3c-des.md) - - [MIPI CSI](driver-platform-mipicsi-des.md) - - [MIPI DSI](driver-platform-mipidsi-des.md) - - [PIN](driver-platform-pin-des.md) - - [PWM](driver-platform-pwm-des.md) - - [Regulator](driver-platform-regulator-des.md) - - [RTC](driver-platform-rtc-des.md) - - [SDIO](driver-platform-sdio-des.md) - - [SPI](driver-platform-spi-des.md) - - [UART](driver-platform-uart-des.md) - - [WatchDog](driver-platform-watchdog-des.md) + - [ADC](driver/driver-platform-adc-des.md) + - [DAC](driver/driver-platform-dac-des.md) + - [GPIO](driver/driver-platform-gpio-des.md) + - [HDMI](driver/driver-platform-hdmi-des.md) + - [I2C](driver/driver-platform-i2c-des.md) + - [I3C](driver/driver-platform-i3c-des.md) + - [MIPI CSI](driver/driver-platform-mipicsi-des.md) + - [MIPI DSI](driver/driver-platform-mipidsi-des.md) + - [PIN](driver/driver-platform-pin-des.md) + - [PWM](driver/driver-platform-pwm-des.md) + - [Regulator](driver/driver-platform-regulator-des.md) + - [RTC](driver/driver-platform-rtc-des.md) + - [SDIO](driver/driver-platform-sdio-des.md) + - [SPI](driver/driver-platform-spi-des.md) + - [UART](driver/driver-platform-uart-des.md) + - [WatchDog](driver/driver-platform-watchdog-des.md) - 外设驱动使用 + - [Audio](driver/driver-peripherals-audio-des.md) + - [Camera](driver/driver-peripherals-camera-des.md) + - [Face_auth](driver/driver-peripherals-face_auth-des.md) - [LCD](driver/driver-peripherals-lcd-des.md) - - [TOUCHSCREEN](driver/driver-peripherals-touch-des.md) - - [SENSOR](driver/driver-peripherals-sensor-des.md) - - [WLAN](driver/driver-peripherals-external-des.md) - - [AUDIO](driver/driver-peripherals-audio-des.md) + - [Light](driver/driver-peripherals-light-des.md) + - [Pin_auth](driver/driver-peripherals-pinauth-des.md) + - [Sensor](driver/driver-peripherals-sensor-des.md) + - [Touchscreen](driver/driver-peripherals-touch-des.md) - [USB](driver/driver-peripherals-usb-des.md) - - [CAMERA](driver/driver-peripherals-camera-des.md) - - [Vibrator](driver-peripherals-vibrator-des.md) - - [Light](driver-peripherals-light-des.md) + - [User_auth](driver/driver-peripherals-user-auth-des.md) + - [Vibrator](driver/driver-peripherals-vibrator-des.md) + - [WLAN](driver/driver-peripherals-external-des.md) - 编译构建 - [轻量和小型系统编译构建指导](subsystems/subsys-build-mini-lite.md) - [标准系统编译构建指导](subsystems/subsys-build-standard-large.md)