diff --git a/en/application-dev/connectivity/http-request.md b/en/application-dev/connectivity/http-request.md index 6204682cde551e1d9a952d8e19716cf342ce2d3d..39ada2bc9b21b8e5d157806f5164c02219c65296 100644 --- a/en/application-dev/connectivity/http-request.md +++ b/en/application-dev/connectivity/http-request.md @@ -30,7 +30,7 @@ The following table provides only a simple description of the related APIs. For | on\('dataProgress'\)10+ | Registers an observer for events indicating progress of receiving HTTP streaming responses. | | off\('dataProgress'\)10+ | Unregisters the observer for events indicating progress of receiving HTTP streaming responses.| -## How to Develop +## How to Develop request APIs 1. Import the **http** namespace from **@ohos.net.http.d.ts**. 2. Call **createHttp()** to create an **HttpRequest** object. @@ -89,3 +89,80 @@ httpRequest.request( } ); ``` + +## How to Develop request2 APIs + +1. Import the **http** namespace from **@ohos.net.http.d.ts**. +2. Call **createHttp()** to create an **HttpRequest** object. +3. Depending on your need, call **on()** of the **HttpRequest** object to subscribe to HTTP response header events as well as events indicating receiving of HTTP streaming responses, progress of receiving HTTP streaming responses, and completion of receiving HTTP streaming responses. +4. Call **request2()** to initiate a network request. You need to pass in the URL and optional parameters of the HTTP request. +5. Parse the returned response code as needed. +6. Call **off()** of the **HttpRequest** object to unsubscribe from the related events. +7. Call **httpRequest.destroy()** to release resources after the request is processed. + +```js +// Import the http namespace. +import http from '@ohos.net.http' + +// Each httpRequest corresponds to an HTTP request task and cannot be reused. +let httpRequest = http.createHttp(); +// Subscribe to HTTP response header events. +httpRequest.on('headersReceive', (header) => { + console.info('header: ' + JSON.stringify(header)); +}); +// Subscribe to events indicating receiving of HTTP streaming responses. +let res = ''; +httpRequest.on('dataReceive', (data) => { + res += data; + console.info('res: ' + res); +}); +// Subscribe to events indicating completion of receiving HTTP streaming responses. +httpRequest.on('dataEnd', () => { + console.info('No more data in response, data receive end'); +}); +// Subscribe to events indicating progress of receiving HTTP streaming responses. +httpRequest.on('dataProgress', (data) => { + console.log("dataProgress receiveSize:" + data.receiveSize+ ", totalSize:" + data.totalSize); +}); + +httpRequest.request2( + // Customize EXAMPLE_URL in extraData on your own. It is up to you whether to add parameters to the URL. + "EXAMPLE_URL", + { + method: http.RequestMethod.POST, // Optional. The default value is http.RequestMethod.GET. + // You can add header fields based on service requirements. + header: { + 'Content-Type': 'application/json' + }, + // This field is used to transfer data when the POST request is used. + extraData: { + "data": "data to send", + }, + expectDataType: http.HttpDataType.STRING, // Optional. This field specifies the type of the return data. + usingCache: true, // Optional. The default value is true. + priority: 1, // Optional. The default value is 1. + connectTimeout: 60000 // Optional. The default value is 60000, in ms. + readTimeout: 60000, // Optional. The default value is 60000, in ms. If a large amount of data needs to be transmitted, you are advised to set this parameter to a larger value to ensure normal data transmission. + usingProtocol: http.HttpProtocol.HTTP1_1, // Optional. The default protocol type is automatically specified by the system. + }, (err, data) => { + console.info('error:' + JSON.stringify(err)); + console.info('ResponseCode :' + JSON.stringify(data)); + // Unsubscribe from HTTP Response Header events. + httpRequest.off('headersReceive'); + // Unregister the observer for events indicating receiving of HTTP streaming responses. + httpRequest.off('dataReceive'); + // Unregister the observer for events indicating progress of receiving HTTP streaming responses. + httpRequest.off('dataProgress'); + // Unregister the observer for events indicating completion of receiving HTTP streaming responses. + httpRequest.off('dataEnd'); + // Call the destroy() method to release resources after HttpRequest is complete. + httpRequest.destroy(); + } +); + +``` + +## Samples +The following sample is provided to help you better understand how to develop the HTTP data request feature: +- [HTTP Data Request (ArkTS) (API9)](https://gitee.com/openharmony/applications_app_samples/tree/master/code/BasicFeature/Connectivity/Http) +- [HTTP Communication (ArkTS) (API9)](https://gitee.com/openharmony/codelabs/tree/master/NetworkManagement/SmartChatEtsOH) diff --git a/en/application-dev/faqs/Readme-EN.md b/en/application-dev/faqs/Readme-EN.md index 7eb9cad6b546996a47e92cd01b03f783a1f4a6d2..63535a32ae16eca13b03d20b4bce93569e2fe1d0 100644 --- a/en/application-dev/faqs/Readme-EN.md +++ b/en/application-dev/faqs/Readme-EN.md @@ -18,5 +18,4 @@ - [Native API Usage](faqs-native.md) - [Usage of Third- and Fourth-Party Libraries](faqs-third-party-library.md) - [IDE Usage](faqs-ide.md) -- [hdc_std Command Usage](faqs-hdc-std.md) - [Development Board](faqs-development-board.md) \ No newline at end of file diff --git a/en/application-dev/faqs/faqs-hdc-std.md b/en/application-dev/faqs/faqs-hdc-std.md deleted file mode 100644 index 60f93da61d7d78a4e148b65c0e30d379b1e1206d..0000000000000000000000000000000000000000 --- a/en/application-dev/faqs/faqs-hdc-std.md +++ /dev/null @@ -1,87 +0,0 @@ -# hdc_std Command Usage - -## Common Log Commands - -Applicable to: OpenHarmony SDK 3.2.2.5 - -Clearing logs: hdc_std shell hilog -r - -Increasing the buffer size to 20 MB: hdc_std shell hilog -G 20M - -Capturing logs: hdc_std shell hilog > log.txt - -## What should I do to avoid log flow control? - -Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9 - -- Disabling log flow control: hdc_std shell hilog -Q pidoff - -- Disabling the privacy flag: hdc_std shell hilog -p off - -- Increasing the log buffer to 200 MB: hdc_std shell hilog -G 200M - -- Enabling the log function of the specific domain (that is, disabling the global log function): hdc_std shell hilog –b D –D 0xd0xxxxx - -After performing the preceding operations, restart the DevEco Studio. - -## What should I do if the HAP installed on the development board through the IDE cannot be opened? - -Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9 - -Check whether the SDK version is consistent with the system version on the development board. You are advised to use the SDK version and system version that are released on the same day. - -## How do I upload files using the hdc command? - -Applicable to: OpenHarmony SDK 3.2.2.5 - -Run the **hdc_std file send** command. - -## How do I prevent the screen of the RK3568 development board from turning off? - -Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9 - -Run the **hdc_std shell "power-shell setmode 602"** command. - -## How do I start an ability using the hdc command? - -Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9 - -Run the **hdc\_std shell aa start -a AbilityName -b bundleName -m moduleName** command. - -## How do I change the read and write permissions on a file directory on the development board? - -Applicable to: OpenHarmony SDK 3.2.5.6, stage model of API version 9 - -Run the **hdc\_std shell mount -o remount,rw /** command. - -## What should I do if the error message "Unknown file option -r" is displayed when hdc_std file recv is run? - -Applicable to: OpenHarmony SDK 3.2.5.6, stage model of API version 9 - -1. Use the the hdc tool in the device image or SDK of the same version. - -2. Remove any Chinese characters or spaces from the directory specified for the hdc tool. - -## How do I uninstall an application using the hdc command? - -Applicable to: OpenHarmony SDK 3.2.2.5 - -Run the **hdc\_std uninstall [-k] [package_name]** command. - -## How do I check whether the system is 32-bit or 64-bit? - -Applicable to: OpenHarmony SDK 3.2.5.5 - -Run the **hdc\_std shell getconf LONG_BIT** command. - -If **64** is returned, the system is a 64-bit one. Otherwise, the system is a 32-bit one. - -## How do I view the component tree structure? - -Applicable to: OpenHarmony SDK 3.2.5.5 - -1. Run the **hdc\_std shell** command to launch the CLI. - -2. Run the **aa dump -a** command to find **abilityID**. - -3. Run the **aa dump -i [abilityID] -c -render** command to view the component tree. diff --git a/en/application-dev/reference/apis/Readme-EN.md b/en/application-dev/reference/apis/Readme-EN.md index 9b3805f5d1b89168c919abdceeb5a4b9512b9d5a..3d791befc09e01d9dda38f359d68485cd97eb2a2 100644 --- a/en/application-dev/reference/apis/Readme-EN.md +++ b/en/application-dev/reference/apis/Readme-EN.md @@ -265,6 +265,7 @@ - [@ohos.net.socket (Socket Connection)](js-apis-socket.md) - [@ohos.net.webSocket (WebSocket Connection)](js-apis-webSocket.md) - [@ohos.request (Upload and Download)](js-apis-request.md) + - [@ohos.net.mdns (mDNS Management)](js-apis-net-mdns.md) - Connectivity - [@ohos.bluetooth (Bluetooth)(To Be Deprecated Soon)](js-apis-bluetooth.md) diff --git a/en/application-dev/reference/apis/js-apis-contact.md b/en/application-dev/reference/apis/js-apis-contact.md index bcc8b36fc9a93191258ed78edb68df61ccce4c28..358d4e95387c3b20401e55ebbbf8e7fa157cfe0f 100644 --- a/en/application-dev/reference/apis/js-apis-contact.md +++ b/en/application-dev/reference/apis/js-apis-contact.md @@ -1,5 +1,7 @@ # @ohos.contact (Contacts) +The **contact** module provides contact management functions, such as adding, deleting, and updating contacts. + >**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. @@ -7,7 +9,7 @@ ## Modules to Import -```js +``` import contact from '@ohos.contact'; ``` @@ -183,7 +185,7 @@ Updates a contact based on the specified contact information. This API uses an a updateContact(contact: Contact, attrs: ContactAttributes, callback: AsyncCallback<void>): void -Updates a contact based on the specified contact information and attributes. This API uses an asynchronous callback to return the result. +Updates a contact based on the specified contact information. This API uses an asynchronous callback to return the result. **Permission required**: ohos.permission.WRITE_CONTACTS @@ -234,7 +236,6 @@ Updates a contact based on the specified contact information and attributes. Thi | attrs | [ContactAttributes](#contactattributes) | No | List of contact attributes.| **Return Value** - | Type | Description | | ------------------- | ------------------------------------------------- | | Promise<void> | Promise used to return the result.| @@ -418,7 +419,7 @@ Queries my card. This API uses an asynchronous callback to return the result. queryMyCard(attrs: ContactAttributes, callback: AsyncCallback<Contact>): void -Queries my card based on the specified contact attributes. This API uses an asynchronous callback to return the result. +Queries my card. This API uses an asynchronous callback to return the result. **Permission required**: ohos.permission.READ_CONTACTS @@ -463,7 +464,6 @@ Queries my card based on the specified contact attributes. This API uses a promi | attrs | [ContactAttributes](#contactattributes) | No | List of contact attributes.| **Return Value** - | Type | Description | | ---------------------------------- | ------------------------------------------- | | Promise<[Contact](#contact)> | Promise used to return the result.| @@ -488,8 +488,6 @@ selectContact(callback: AsyncCallback<Array<Contact>>): void Selects a contact. This API uses an asynchronous callback to return the result. -**Permission required**: ohos.permission.READ_CONTACTS - **System capability**: SystemCapability.Applications.Contacts **Parameters** @@ -517,8 +515,6 @@ selectContact(): Promise<Array<Contact>> Selects a contact. This API uses a promise to return the result. -**Permission required**: ohos.permission.READ_CONTACTS - **System capability**: SystemCapability.Applications.Contacts **Return Value** @@ -573,7 +569,7 @@ Queries a contact based on the specified key. This API uses an asynchronous call queryContact(key: string, holder: Holder, callback: AsyncCallback<Contact>): void -Queries contacts based on the specified key and application. This API uses an asynchronous callback to return the result. +Queries a contact based on the specified key. This API uses an asynchronous callback to return the result. **Permission required**: ohos.permission.READ_CONTACTS @@ -608,7 +604,7 @@ Queries contacts based on the specified key and application. This API uses an as queryContact(key: string, attrs: ContactAttributes, callback: AsyncCallback<Contact>): void -Queries contacts based on the specified key and attributes. This API uses an asynchronous callback to return the result. +Queries a contact based on the specified key. This API uses an asynchronous callback to return the result. **Permission required**: ohos.permission.READ_CONTACTS @@ -641,7 +637,7 @@ Queries contacts based on the specified key and attributes. This API uses an asy queryContact(key: string, holder: Holder, attrs: ContactAttributes, callback: AsyncCallback<Contact>): void -Queries contacts based on the specified key, application, and attributes. This API uses an asynchronous callback to return the result. +Queries a contact based on the specified key. This API uses an asynchronous callback to return the result. **Permission required**: ohos.permission.READ_CONTACTS @@ -660,7 +656,6 @@ Queries contacts based on the specified key, application, and attributes. This A ```js contact.queryContact('xxx', { - holderId: 0 holderId: 0, bundleName: "", displayName: "" @@ -695,7 +690,6 @@ Queries contacts based on the specified key, application, and attributes. This A | attrs | [ContactAttributes](#contactattributes) | No | List of contact attributes. | **Return Value** - | Type | Description | | ---------------------------------- | ----------------------------------------------- | | Promise<[Contact](#contact)> | Promise used to return the result.| @@ -704,7 +698,6 @@ Queries contacts based on the specified key, application, and attributes. This A ```js let promise = contact.queryContact('xxx', { - holderId: 0 holderId: 0, bundleName: "", displayName: "" @@ -752,7 +745,7 @@ Queries all contacts. This API uses an asynchronous callback to return the resul queryContacts(holder: Holder, callback: AsyncCallback<Array<Contact>>): void -Queries all contacts based on the specified application. This API uses an asynchronous callback to return the result. +Queries all contacts. This API uses an asynchronous callback to return the result. **Permission required**: ohos.permission.READ_CONTACTS @@ -786,7 +779,7 @@ Queries all contacts based on the specified application. This API uses an asynch queryContacts(attrs: ContactAttributes, callback: AsyncCallback<Array<Contact>>): void -Queries all contacts based on the specified attributes. This API uses an asynchronous callback to return the result. +Queries all contacts. This API uses an asynchronous callback to return the result. **Permission required**: ohos.permission.READ_CONTACTS @@ -818,7 +811,7 @@ Queries all contacts based on the specified attributes. This API uses an asynchr queryContacts(holder: Holder, attrs: ContactAttributes, callback: AsyncCallback<Array<Contact>>): void -Queries all contacts based on the specified application and attributes. This API uses an asynchronous callback to return the result. +Queries all contacts. This API uses an asynchronous callback to return the result. **Permission required**: ohos.permission.READ_CONTACTS @@ -869,7 +862,6 @@ Queries all contacts based on the specified application and attributes. This API | attrs | [ContactAttributes](#contactattributes) | No | List of contact attributes. | **Return Value** - | Type | Description | | ----------------------------------------------- | --------------------------------------------------- | | Promise<Array<[Contact](#contact)>> | Promise used to return the result.| @@ -926,7 +918,7 @@ Queries contacts based on the specified phone number. This API uses an asynchron queryContactsByPhoneNumber(phoneNumber: string, holder: Holder, callback: AsyncCallback<Array<Contact>>): void -Queries contacts based on the specified phone number and application. This API uses an asynchronous callback to return the result. +Queries contacts based on the specified phone number. This API uses an asynchronous callback to return the result. **Permission required**: ohos.permission.READ_CONTACTS @@ -961,7 +953,7 @@ Queries contacts based on the specified phone number and application. This API u queryContactsByPhoneNumber(phoneNumber: string, attrs: ContactAttributes, callback: AsyncCallback<Array<Contact>>): void -Queries contacts based on the specified phone number and attributes. This API uses an asynchronous callback to return the result. +Queries contacts based on the specified phone number. This API uses an asynchronous callback to return the result. **Permission required**: ohos.permission.READ_CONTACTS @@ -994,7 +986,7 @@ Queries contacts based on the specified phone number and attributes. This API us queryContactsByPhoneNumber(phoneNumber: string, holder: Holder, attrs: ContactAttributes, callback: AsyncCallback<Array<Contact>>): void -Queries contacts based on the specified phone number, application, and attributes. This API uses an asynchronous callback to return the result. +Queries contacts based on the specified phone number. This API uses an asynchronous callback to return the result. **Permission required**: ohos.permission.READ_CONTACTS @@ -1104,7 +1096,7 @@ Queries contacts based on the specified email address. This API uses an asynchro queryContactsByEmail(email: string, holder: Holder, callback: AsyncCallback<Array<Contact>>): void -Queries contacts based on the specified email address and application. This API uses an asynchronous callback to return the result. +Queries contacts based on the specified email address. This API uses an asynchronous callback to return the result. **Permission required**: ohos.permission.READ_CONTACTS @@ -1122,7 +1114,7 @@ Queries contacts based on the specified email address and application. This API ```js contact.queryContactsByEmail('xxx@email.com', { - holderId: 0, + holderId: 0, bundleName: "", displayName: "" }, (err, data) => { @@ -1139,7 +1131,7 @@ Queries contacts based on the specified email address and application. This API queryContactsByEmail(email: string, attrs: ContactAttributes, callback: AsyncCallback<Array<Contact>>): void -Queries contacts based on the specified email address and attributes. This API uses an asynchronous callback to return the result. +Queries contacts based on the specified email address. This API uses an asynchronous callback to return the result. **Permission required**: ohos.permission.READ_CONTACTS @@ -1172,7 +1164,7 @@ Queries contacts based on the specified email address and attributes. This API u queryContactsByEmail(email: string, holder: Holder, attrs: ContactAttributes, callback: AsyncCallback<Array<Contact>>): void -Queries contacts based on the specified email address, application, and attributes. This API uses an asynchronous callback to return the result. +Queries contacts based on the specified email address. This API uses an asynchronous callback to return the result. **Permission required**: ohos.permission.READ_CONTACTS @@ -1281,7 +1273,7 @@ Queries all groups of this contact. This API uses an asynchronous callback to re queryGroups(holder: Holder, callback: AsyncCallback<Array<Group>>): void -Queries all groups of this contact based on the specified application. This API uses an asynchronous callback to return the result. +Queries all groups of this contact. This API uses an asynchronous callback to return the result. **Permission required**: ohos.permission.READ_CONTACTS @@ -1440,7 +1432,7 @@ Queries the key of a contact based on the specified contact ID. This API uses an queryKey(id: number, holder: Holder, callback: AsyncCallback<string>): void -Queries the key of a contact based on the specified contact ID and application. This API uses an asynchronous callback to return the result. +Queries the key of a contact based on the specified contact ID. This API uses an asynchronous callback to return the result. **Permission required**: ohos.permission.READ_CONTACTS @@ -1525,7 +1517,7 @@ Defines a contact. ### Attributes -| Name | Type | Readable| Writable| Description | +| Name | Type | Readable| Writable| Description | | ----------------- | --------------------------------------- | ---- | ---- | -------------------------------------- | | id | number | Yes | No | Contact ID. | | key | string | Yes | No | Contact key. | @@ -1587,7 +1579,7 @@ If **null** is passed, all attributes are queried by default. **System capability**: SystemCapability.Applications.ContactsData -| Name | Type | Readable| Writable| Description | +| Name | Type | Readable| Writable| Description | | ---------- | ------------------------- | ---- | ---- | ---------------- | | attributes | [Attribute](#attribute)[] | Yes | Yes | List of contact attributes.| @@ -1668,7 +1660,7 @@ Defines a contact's email. ### Attributes -| Name | Type| Readable| Writable| Description | +| Name | Type | Readable| Writable| Description | | ----------- | -------- | ---- | ---- | ---------------- | | email | string | Yes | Yes | Email addresses | | labelName | string | Yes | Yes | Name of the mailbox type.| @@ -1702,11 +1694,11 @@ Defines an application that creates the contact. **System capability**: SystemCapability.Applications.ContactsData -| Name | Type| Readable| Writable| Description | -| ----------- | -------- | ---- | ---- | ---------- | -| bundleName | string | Yes | No | Bundle name. | -| displayName | string | Yes | No | Application name.| -| holderId | number | Yes | Yes | Application ID. | +| Name | Type | Readable| Writable| Description | +| ----------- | ------ | ---- | ---- | ------------ | +| bundleName | string | Yes | No | Bundle name.| +| displayName | string | Yes | No | Application name. | +| holderId | number | Yes | Yes | Application ID. | **Example** @@ -1746,7 +1738,7 @@ Defines a contact's event. ### Attributes -| Name | Type| Readable| Writable| Description | +| Name | Type | Readable| Writable| Description | | --------- | -------- | ---- | ---- | -------------- | | eventDate | string | Yes | Yes | Event date. | | labelName | string | Yes | Yes | Event type.| @@ -1777,7 +1769,7 @@ Defines a contact group. **System capability**: SystemCapability.Applications.ContactsData -| Name | Type| Readable| Writable| Description | +| Name | Type | Readable| Writable| Description | | ------- | -------- | ---- | ---- | ------------------ | | groupId | number | Yes | Yes | ID of a contact group. | | title | string | Yes | Yes | Name of a contact group.| @@ -1825,7 +1817,7 @@ Enumerates IM addresses. ### Attributes -| Name | Type| Readable| Writable| Description | +| Name | Type | Readable| Writable| Description | | --------- | -------- | ---- | ---- | ------------------ | | imAddress | string | Yes | Yes | IM address. | | labelName | string | Yes | Yes | IM name.| @@ -1858,7 +1850,7 @@ Defines a contact's name. **System capability**: SystemCapability.Applications.ContactsData -| Name | Type| Readable| Writable| Description | +| Name | Type | Readable| Writable| Description | | ------------------ | -------- | ---- | ---- | --------------------------- | | familyName | string | Yes | Yes | Family name. | | familyNamePhonetic | string | Yes | Yes | Family name in pinyin. | @@ -1897,7 +1889,7 @@ Defines a contact's nickname. **System capability**: SystemCapability.Applications.ContactsData -| Name | Type| Readable| Writable| Description | +| Name | Type | Readable| Writable| Description | | -------- | -------- | ---- | ---- | -------------- | | nickName | string | Yes | Yes | Contact nickname.| @@ -1926,7 +1918,7 @@ Defines a contact's note. **System capability**: SystemCapability.Applications.ContactsData -| Name | Type| Readable| Writable| Description | +| Name | Type | Readable| Writable| Description | | ----------- | -------- | ---- | ---- | ------------------ | | noteContent | string | Yes | Yes | Notes of the contact.| @@ -1955,7 +1947,7 @@ Defines a contact's organization. **System capability**: SystemCapability.Applications.ContactsData -| Name | Type| Readable| Writable| Description | +| Name | Type | Readable| Writable| Description | | ----- | -------- | ---- | ---- | ---------- | | name | string | Yes | Yes | Organization name.| | title | string | Yes | Yes | Organization title.| @@ -2017,7 +2009,7 @@ Defines a contact's phone number. ### Attributes -| Name | Type| Readable| Writable| Description | +| Name | Type | Readable| Writable| Description | | ----------- | -------- | ---- | ---- | ------------------ | | labelName | string | Yes | Yes | Phone number type.| | phoneNumber | string | Yes | Yes | Phone number. | @@ -2049,7 +2041,7 @@ Defines a contact's portrait. **System capability**: SystemCapability.Applications.ContactsData -| Name| Type| Readable| Writable| Description | +| Name| Type | Readable| Writable| Description | | ---- | -------- | ---- | ---- | -------------- | | uri | string | Yes | Yes | Contact portrait.| @@ -2091,7 +2083,7 @@ Defines a contact's postal address. ### Attributes -| Name | Type| Readable| Writable| Description | +| Name | Type | Readable| Writable| Description | | ------------- | -------- | ---- | ---- | -------------------------- | | city | string | Yes | Yes | City where the contact is located. | | country | string | Yes | Yes | Country/Region where the contact is located. | @@ -2153,7 +2145,7 @@ Defines a contact's relationship. ### Attributes -| Name | Type| Readable| Writable| Description | +| Name | Type | Readable| Writable| Description | | ------------ | -------- | ---- | ---- | -------------- | | labelName | string | Yes | Yes | Relationship type.| | relationName | string | Yes | Yes | Relationship name. | @@ -2199,13 +2191,12 @@ Defines a contact's SIP address. ### Attributes -| Name | Type| Readable| Writable| Description | +| Name | Type | Readable| Writable| Description | | ---------- | -------- | ---- | ---- | --------------------------------- | | labelName | string | Yes | Yes | SIP address type.| | sipAddress | string | Yes | Yes | SIP address. | | labelId | number | Yes | Yes | SIP address ID. | - **Example** Create contact data in JSON format: @@ -2230,7 +2221,7 @@ Defines a contact's website. **System capability**: SystemCapability.Applications.ContactsData -| Name | Type| Readable| Writable| Description | +| Name | Type | Readable| Writable| Description | | ------- | -------- | ---- | ---- | ------------------ | | website | string | Yes | Yes | Website of the contact.| @@ -2250,4 +2241,4 @@ let website = { ```js let website = new contact.Website(); website.website = "website"; -``` \ No newline at end of file +``` diff --git a/en/application-dev/reference/apis/js-apis-http.md b/en/application-dev/reference/apis/js-apis-http.md index e884f1f348b6754b4f8c8703220a1dcd8a4eb19d..1d0ef9bbc8c424b0e6538a55993cc5f993f7af20 100644 --- a/en/application-dev/reference/apis/js-apis-http.md +++ b/en/application-dev/reference/apis/js-apis-http.md @@ -16,7 +16,7 @@ import http from '@ohos.net.http'; ## Examples ```js -// Import the HTTP namespace. +// Import the http namespace. import http from '@ohos.net.http'; // Each httpRequest corresponds to an HTTP request task and cannot be reused. @@ -112,7 +112,7 @@ Initiates an HTTP request to a given URL. This API uses an asynchronous callback **Error codes** -| ID | Error Message | +| Code | Error Message | |---------|-------------------------------------------------------| | 401 | Parameter error. | | 201 | Permission denied. | @@ -164,7 +164,7 @@ Initiates an HTTP request containing specified options to a given URL. This API **Error codes** -| ID | Error Message | +| Code | Error Message | |---------|-------------------------------------------------------| | 401 | Parameter error. | | 201 | Permission denied. | @@ -255,7 +255,7 @@ Initiates an HTTP request containing specified options to a given URL. This API **Error codes** -| ID | Error Message | +| Code | Error Message | |---------|-------------------------------------------------------| | 401 | Parameter error. | | 201 | Permission denied. | @@ -349,7 +349,7 @@ Initiates an HTTP request to a given URL. This API uses an asynchronous callback **Error codes** -| ID | Error Message | +| Code | Error Message | |---------|-------------------------------------------------------| | 401 | Parameter error. | | 201 | Permission denied. | @@ -395,7 +395,7 @@ Initiates an HTTP request to a given URL. This API uses an asynchronous callback **Error codes** -| ID | Error Message | +| Code | Error Message | |---------|-------------------------------------------------------| | 401 | Parameter error. | | 201 | Permission denied. | @@ -477,7 +477,7 @@ Initiates an HTTP request containing specified options to a given URL. This API **Error codes** -| ID | Error Message | +| Code | Error Message | |---------|-------------------------------------------------------| | 401 | Parameter error. | | 201 | Permission denied. | @@ -513,7 +513,7 @@ Initiates an HTTP request containing specified options to a given URL. This API >**NOTE** > For details about the error codes, see [HTTP Error Codes](../errorcodes/errorcode-net-http.md). -> The HTTP error code mapping is in the format of 2300000 + Curl error code. For more common error codes, see: +> The HTTP error code mapping is in the format of 2300000 + Curl error code. For more common error codes, see [Curl Error Codes](https://curl.se/libcurl/c/libcurl-errors.html). **Example** @@ -540,7 +540,7 @@ on(type: 'headerReceive', callback: AsyncCallback\): void Registers an observer for HTTP Response Header events. >**NOTE** ->This API has been deprecated. You are advised to use [on('headersReceive')8+](#onheadersreceive8) instead. +>This API has been deprecated. You are advised to use [on('headersReceive')8+](#onheadersreceive8). **System capability**: SystemCapability.Communication.NetStack @@ -567,7 +567,7 @@ Unregisters the observer for HTTP Response Header events. >**NOTE** > ->1. This API has been deprecated. You are advised to use [off('headersReceive')8+](#offheadersreceive8) instead. +>1. This API has been deprecated. You are advised to use [off('headersReceive')8+](#offheadersreceive8). > >2. You can pass the callback of the **on** function if you want to cancel listening for a certain type of event. If you do not pass the callback, you will cancel listening for all events. @@ -839,7 +839,7 @@ Enumerates the response codes for an HTTP request. | Name | Value | Description | | ----------------- | ---- | ------------------------------------------------------------ | -| OK | 200 | "OK." The request has been processed successfully. This return code is generally used for GET and POST requests. | +| OK | 200 | The request is successful. The request has been processed successfully. This return code is generally used for GET and POST requests. | | CREATED | 201 | "Created." The request has been successfully sent and a new resource is created. | | ACCEPTED | 202 | "Accepted." The request has been accepted, but the processing has not been completed. | | NOT_AUTHORITATIVE | 203 | "Non-Authoritative Information." The request is successful. | diff --git a/en/application-dev/reference/apis/js-apis-i18n.md b/en/application-dev/reference/apis/js-apis-i18n.md index 2a85da3460cf4dff87a3076686a8b31ae136f65a..db85444d68f958ed8af462815a2865ddc02adc0f 100644 --- a/en/application-dev/reference/apis/js-apis-i18n.md +++ b/en/application-dev/reference/apis/js-apis-i18n.md @@ -2112,6 +2112,75 @@ Obtains the sequence of the year, month, and day in the specified locale. ``` +## Normalizer10+ + +### getInstance10+ + +static getInstance(mode: NormalizerMode): Normalizer + +Obtains a **Normalizer** object for text normalization. + +**System capability**: SystemCapability.Global.I18n + +**Parameters** + +| Name | Type | Mandatory | Description | +| ------ | ------ | ---- | ------------------------- | +| mode | [NormalizerMode](#normalizermode10) | Yes | Text normalization mode.| + +**Return value** + +| Type | Description | +| ------ | ------------------- | +| [Normalizer](#normalizer10) | **Normalizer** object for text normalization.| + +**Example** + ```js + let normalizer = I18n.Normalizer.getInstance(I18n.NormalizerMode.NFC); + ``` + + +### normalize10+ + +normalize(text: string): string + +Normalizes text strings. + +**System capability**: SystemCapability.Global.I18n + +**Parameters** + +| Name | Type | Mandatory | Description | +| ------ | ------ | ---- | ------------------------- | +| text | string | Yes | Text strings to be normalized.| + +**Return value** + +| Type | Description | +| ------ | ------------------- | +| string | Normalized text strings.| + +**Example** + ```js + let normalizer = I18n.Normalizer.getInstance(I18n.NormalizerMode.NFC); + let normalizedText = normalizer.normalize('\u1E9B\u0323'); // normalizedText = \u1E9B\u0323 + ``` + + +## NormalizerMode10+ + +Enumerates text normalization modes. + +**System capability**: SystemCapability.Global.I18n + +| Name| Value| Description| +| -------- | -------- | -------- | +| NFC | 1 | NFC.| +| NFD | 2 | NFD.| +| NFKC | 3 | NFKC.| +| NFKD | 4 | NFKD.| + + ## I18n.getDisplayCountry(deprecated) getDisplayCountry(country: string, locale: string, sentenceCase?: boolean): string diff --git a/en/application-dev/reference/apis/js-apis-net-mdns.md b/en/application-dev/reference/apis/js-apis-net-mdns.md new file mode 100644 index 0000000000000000000000000000000000000000..b2e157c03a7afec840f4af21aa729f3c081e540a --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-net-mdns.md @@ -0,0 +1,551 @@ +# @ohos.net.mdns (mDNS Management) + +Multicast DNS (mDNS) provides functions such as adding, removing, discovering, and resolving local services on a LAN. + +> **NOTE** +> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version. + +## Modules to Import + +```js +import mdns from '@ohos.net.mdns' +``` +## mdns.addLocalService + +addLocalService(context: Context, serviceInfo: LocalServiceInfo, callback: AsyncCallback\): void + +Adds an mDNS service. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Communication.NetManager.MDNS + +**Parameters** + +| Name | Type | Mandatory| Description | +|-------------|----------------------------------|-----------|-------------------------------------------------| +| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-inner-application-uiAbilityContext.md).| +| serviceInfo | [LocalServiceInfo](#localserviceinfo) | Yes | mDNS service information. | +| callback | AsyncCallback\<[LocalServiceInfo](#localserviceinfo)> | Yes | Callback used to return the result. If the operation is successful, **error** is **undefined** and **data** is the mDNS service information. | + +**Error codes** + +| ID | Error Message| +|---------|---| +| 401 | Parameter error. | +| 2100002 | Operation failed. Cannot connect to service. | +| 2100003 | System internal error. | +| 2204003 | Callback duplicated. | +| 2204008 | Service instance duplicated. | +| 2204010 | Send packet failed. | + +>**NOTE** +> For details about the error codes, see [mDNS Error Codes](../errorcodes/errorcode-net-mdns.md). + +**Example** + +```js +let localServiceInfo = { + serviceType: "_print._tcp", + serviceName: "servicename", + port: 5555, + host: { + address: "10.14.**.***", + }, + serviceAttribute: [{ + key: "111", + value: [1] + }] +} + +mdns.addLocalService(context, localServiceInfo, function (error, data) { + console.log(JSON.stringify(error)) + console.log(JSON.stringify(data)) +}); +``` + +## mdns.addLocalService + +addLocalService(context: Context, serviceInfo: LocalServiceInfo): Promise\ + +Adds an mDNS service. This API uses a promise to return the result. + +**System capability**: SystemCapability.Communication.NetManager.MDNS + +**Parameters** + +| Name | Type | Mandatory| Description | +|-------------|----------------------------------|-----------|-------------------------------------------------| +| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-inner-application-uiAbilityContext.md).| +| serviceInfo | [LocalServiceInfo](#localserviceinfo) | Yes | mDNS service information. | + +**Return value** + +| Type | Description | +| --------------------------------- | ------------------------------------- | +| Promise\<[LocalServiceInfo](#localserviceinfo)> | Promise used to return the result.| + +**Error codes** + +| ID | Error Message| +|---------|---| +| 401 | Parameter error. | +| 2100002 | Operation failed. Cannot connect to service. | +| 2100003 | System internal error. | +| 2204003 | Callback duplicated. | +| 2204008 | Service instance duplicated. | +| 2204010 | Send packet failed. | + +>**NOTE** +> For details about the error codes, see [mDNS Error Codes](../errorcodes/errorcode-net-mdns.md). + +**Example** + +```js +let localServiceInfo = { + serviceType: "_print._tcp", + serviceName: "servicename", + port: 5555, + host: { + address: "10.14.**.***", + }, + serviceAttribute: [{ + key: "111", + value: [1] + }] +} + +mdns.addLocalService(context, localServiceInfo).then(function (data) { + console.log(JSON.stringify(data)) +}); +``` + +## mdns.removeLocalService + +removeLocalService(context: Context, serviceInfo: LocalServiceInfo, callback: AsyncCallback\): void + +Removes an mDNS service. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Communication.NetManager.MDNS + +**Parameters** + +| Name | Type | Mandatory| Description | +|-------------|----------------------------------|-----------|-------------------------------------------------| +| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-inner-application-uiAbilityContext.md).| +| serviceInfo | [LocalServiceInfo](#localserviceinfo) | Yes | mDNS service information. | +| callback | AsyncCallback\<[LocalServiceInfo](#localserviceinfo)> | Yes | Callback used to return the result. If the operation is successful, **error** is **undefined** and **data** is the mDNS service information. | + +**Error codes** + +| ID | Error Message| +|---------|---| +| 401 | Parameter error. | +| 2100002 | Operation failed. Cannot connect to service. | +| 2100003 | System internal error. | +| 2204002 | Callback not found. | +| 2204008 | Service instance duplicated. | +| 2204010 | Send packet failed. | + +>**NOTE** +> For details about the error codes, see [mDNS Error Codes](../errorcodes/errorcode-net-mdns.md). + +**Example** + +```js +let localServiceInfo = { + serviceType: "_print._tcp", + serviceName: "servicename", + port: 5555, + host: { + address: "10.14.**.***", + }, + serviceAttribute: [{ + key: "111", + value: [1] + }] +} + +mdns.removeLocalService(context, localServiceInfo, function (error, data) { + console.log(JSON.stringify(error)) + console.log(JSON.stringify(data)) +}); +``` + +## mdns.removeLocalService + +removeLocalService(context: Context, serviceInfo: LocalServiceInfo): Promise\ + +Removes an mDNS service. This API uses a promise to return the result. + +**System capability**: SystemCapability.Communication.NetManager.MDNS + +**Parameters** + +| Name | Type | Mandatory| Description | +|-------------|----------------------------------|-----------|-------------------------------------------------| +| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-inner-application-uiAbilityContext.md).| +| serviceInfo | [LocalServiceInfo](#localserviceinfo) | Yes | mDNS service information. | + +**Return value** + +| Type | Description | +| --------------------------------- | ------------------------------------- | +| Promise\<[LocalServiceInfo](#localserviceinfo)> | Promise used to return the result.| + +**Error codes** + +| ID | Error Message| +|---------|---| +| 401 | Parameter error. | +| 2100002 | Operation failed. Cannot connect to service. | +| 2100003 | System internal error. | +| 2204002 | Callback not found. | +| 2204008 | Service instance duplicated. | +| 2204010 | Send packet failed. | + +>**NOTE** +> For details about the error codes, see [mDNS Error Codes](../errorcodes/errorcode-net-mdns.md). + +**Example** + +```js +let localServiceInfo = { + serviceType: "_print._tcp", + serviceName: "servicename", + port: 5555, + host: { + address: "10.14.**.***", + }, + serviceAttribute: [{ + key: "111", + value: [1] + }] +} + +mdns.removeLocalService(context, localServiceInfo).then(function (data) { + console.log(JSON.stringify(data)) +}); +``` + +## mdns.createDiscoveryService + +createDiscoveryService(context: Context, serviceType: string): DiscoveryService + +Creates a **DiscoveryService** object, which is used to discover mDNS services of the specified type. + +**System capability**: SystemCapability.Communication.NetManager.MDNS + +**Parameters** + +| Name | Type | Mandatory| Description | +|-------------|---------|-----------| ------------------------------------------------------------ | +| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-inner-application-uiAbilityContext.md).| +| serviceType | string | Yes | Type of the mDNS services to be discovered.| + +**Return value** + +| Type | Description | +| ----------------------------- |---------------------------------| +| DiscoveryService | **DiscoveryService** object used to discover mDNS services of the specified type.| + +**Example** + +```js +let serviceType = "_print._tcp"; + +let discoveryService = mdns.createDiscoveryService(context, serviceType); +``` + +## mdns.resolveLocalService + +resolveLocalService(context: Context, serviceInfo: LocalServiceInfo, callback: AsyncCallback\): void + +Resolves an mDNS service. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Communication.NetManager.MDNS + +**Parameters** + +| Name | Type | Mandatory| Description | +|-------------|----------------------------------|-----------|-------------------------------------------------------------| +| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-inner-application-uiAbilityContext.md).| +| serviceInfo | [LocalServiceInfo](#localserviceinfo) | Yes | mDNS service information. | +| callback | AsyncCallback\<[LocalServiceInfo](#localserviceinfo)> | Yes | Callback used to return the result. If the operation is successful, **error** is **undefined** and **data** is the mDNS service information. | + +**Error codes** + +| ID | Error Message| +|---------|----------------------------------------------| +| 401 | Parameter error. | +| 2100002 | Operation failed. Cannot connect to service. | +| 2100003 | System internal error. | +| 2204003 | Callback duplicated. | +| 2204006 | Request timeout. | +| 2204010 | Send packet failed. | + +>**NOTE** +> For details about the error codes, see [mDNS Error Codes](../errorcodes/errorcode-net-mdns.md). + +**Example** + +```js +let localServiceInfo = { + serviceType: "_print._tcp", + serviceName: "servicename", + port: 5555, + host: { + address: "10.14.**.***", + }, + serviceAttribute: [{ + key: "111", + value: [1] + }] +} + +mdns.resolveLocalService(context, localServiceInfo, function (error, data) { + console.log(JSON.stringify(error)) + console.log(JSON.stringify(data)) +}); +``` + +## mdns.resolveLocalService + +resolveLocalService(context: Context, serviceInfo: LocalServiceInfo): Promise\ + +Resolves an mDNS service. This API uses a promise to return the result. + +**System capability**: SystemCapability.Communication.NetManager.MDNS + +**Parameters** + +| Name | Type | Mandatory| Description | +|-------------|--------------|-----------|-----------------------------------------------------| +| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-inner-application-uiAbilityContext.md).| +| serviceInfo | [LocalServiceInfo](#localserviceinfo) | Yes | mDNS service information. | + +**Return value** + +| Type | Description | +|----------------------------| ------------------------------------- | +| Promise\<[LocalServiceInfo](#localserviceinfo)> | Promise used to return the result.| + +**Error codes** + +| ID | Error Message| +|---------|----------------------------------------------| +| 401 | Parameter error. | +| 2100002 | Operation failed. Cannot connect to service. | +| 2100003 | System internal error. | +| 2204003 | Callback duplicated. | +| 2204006 | Request timeout. | +| 2204010 | Send packet failed. | + +>**NOTE** +> For details about the error codes, see [mDNS Error Codes](../errorcodes/errorcode-net-mdns.md). + +**Example** + +```js +let localServiceInfo = { + serviceType: "_print._tcp", + serviceName: "servicename", + port: 5555, + host: { + address: "10.14.**.***", + }, + serviceAttribute: [{ + key: "111", + value: [1] + }] +} + +mdns.resolveLocalService(context, localServiceInfo).then(function (data){ + console.log(JSON.stringify(data)); +}) +``` + +## DiscoveryService + +Defines a **DiscoveryService** object for discovering mDNS services of the specified type. + +### startSearchingMDNS + +startSearchingMDNS(): void + +Searches for mDNS services on the LAN. + +**System capability**: SystemCapability.Communication.NetManager.MDNS + +**Example** + +```js +let discoveryService = mdns.createDiscoveryService(context, serviceType); +discoveryService.startSearchingMDNS(); +``` + +### stopSearchingMDNS + +stopSearchingMDNS(): void + +Stops searching for mDNS services on the LAN. + +**System capability**: SystemCapability.Communication.NetManager.MDNS + +**Example** + +```js +let discoveryService = mdns.createDiscoveryService(context, serviceType); +discoveryService.stopSearchingMDNS(); +``` + +### on('discoveryStart') + +on(type: 'discoveryStart', callback: Callback<{serviceInfo: LocalServiceInfo, errorCode?: MDNS_ERR}>): void + +Enables listening for **discoveryStart** events. + +**System capability**: SystemCapability.Communication.NetManager.MDNS + +**Parameters** + +| Name | Type | Mandatory| Description | +|-------------|--------------|-----------|-----------------------------------------------------| +| type | string | Yes |Event type. This field has a fixed value of **discoveryStart**.
**discoveryStart**: event of starting discovery of mDNS services on the LAN.| +| callback | Callback<{serviceInfo: [LocalServiceInfo](#localserviceinfo), errorCode?: [MDNS_ERR](#mdns_err)}> | Yes | Callback used to return the mDNS service and error information. | + +**Example** + +```js +// See mdns.createDiscoveryService. +let discoveryService = mdns.createDiscoveryService(context, serviceType); +discoveryService.startSearchingMDNS(); + +discoveryService.on('discoveryStart', (data) => { + console.log(JSON.stringify(data)); +}); + +discoveryService.stopSearchingMDNS(); +``` + +### on('discoveryStop') + +on(type: 'discoveryStop', callback: Callback<{serviceInfo: LocalServiceInfo, errorCode?: MDNS_ERR}>): void + +Enables listening for **discoveryStop** events. + +**System capability**: SystemCapability.Communication.NetManager.MDNS + +**Parameters** + +| Name | Type | Mandatory| Description | +|-------------|--------------|-----------|-----------------------------------------------------| +| type | string | Yes |Event type. This field has a fixed value of **discoveryStop**.
**discoveryStop**: event of stopping discovery of mDNS services on the LAN.| +| callback | Callback<{serviceInfo: [LocalServiceInfo](#localserviceinfo), errorCode?: [MDNS_ERR](#mdns_err)}> | Yes | Callback used to return the mDNS service and error information. | + +**Example** + +```js +// See mdns.createDiscoveryService. +let discoveryService = mdns.createDiscoveryService(context, serviceType); +discoveryService.startSearchingMDNS(); + +discoveryService.on('discoveryStop', (data) => { + console.log(JSON.stringify(data)); +}); + +discoveryService.stopSearchingMDNS(); +``` + +### on('serviceFound') + +on(type: 'serviceFound', callback: Callback<[LocalServiceInfo](#localserviceinfo)>): void + +Enables listening for **serviceFound** events. + +**System capability**: SystemCapability.Communication.NetManager.MDNS + +**Parameters** + +| Name | Type | Mandatory| Description | +|-------------|--------------|-----------|-----------------------------------------------------| +| type | string | Yes |Event type. This field has a fixed value of **serviceFound**.
**serviceFound**: event indicating an mDNS service is found.| +| callback | Callback<[LocalServiceInfo](#localserviceinfo)> | Yes | mDNS service information. | + +**Example** + +```js +// See mdns.createDiscoveryService. +let discoveryService = mdns.createDiscoveryService(context, serviceType); +discoveryService.startSearchingMDNS(); + +discoveryService.on('serviceFound', (data) => { + console.log(JSON.stringify(data)); +}); + +discoveryService.stopSearchingMDNS(); +``` + +### on('serviceLost') + +on(type: 'serviceLost', callback: Callback<[LocalServiceInfo](#localserviceinfo)>): void + +Enables listening for **serviceLost** events. + +**System capability**: SystemCapability.Communication.NetManager.MDNS + +**Parameters** + +| Name | Type | Mandatory| Description | +|-------------|--------------|-----------|-----------------------------------------------------| +| type | string | Yes |Event type. This field has a fixed value of **serviceLost**.
serviceLost: event indicating that an mDNS service is removed.| +| callback | Callback<[LocalServiceInfo](#localserviceinfo)> | Yes | mDNS service information. | + +**Example** + +```js +// See mdns.createDiscoveryService. +let discoveryService = mdns.createDiscoveryService(context, serviceType); +discoveryService.startSearchingMDNS(); + +discoveryService.on('serviceLost', (data) => { + console.log(JSON.stringify(data)); +}); + +discoveryService.stopSearchingMDNS(); +``` + +## LocalServiceInfo + +Defines the mDNS service information. + +**System capability**: SystemCapability.Communication.NetManager.MDNS + +| Name | Type | Mandatory| Description | +| --------------------- | ---------------------------------- | --- | ------------------------ | +| serviceType | string | Yes| Type of the mDNS service. The value is in the format of **\_\.\**, where **name** contains a maximum of 63 characters excluding periods (.). | +| serviceName | string | Yes| Name of the mDNS service. | +| port | number | No| Port number of the mDNS server. | +| host | [NetAddress](js-apis-net-connection.md#netaddress) | No| IP address of the device that provides the mDNS service. The IP address is not effective when an mDNS service is added or removed. | +| serviceAttribute | serviceAttribute\<[ServiceAttribute](#serviceattribute)> | No| mDNS service attribute information. | + +## ServiceAttribute + +Defines the mDNS service attribute information. + +**System capability**: SystemCapability.Communication.NetManager.MDNS + +| Name | Type | Mandatory| Description | +| --------------------- | ---------------------------------- | --- | ------------------------ | +| key | string | Yes| mDNS service attribute key. The value contains a maximum of 9 characters. | +| value | Array\ | Yes| mDNS service attribute value. | + +## MDNS_ERR + +Defines the mDNS error information. + +**System capability**: SystemCapability.Communication.NetManager.MDNS + +| Name | Value | Description | +| --------------- | ---- | ----------- | +| INTERNAL_ERROR | 0 | Operation failed because of an internal error. | +| ALREADY_ACTIVE | 1 | Operation failed because the service already exists.| +| MAX_LIMIT | 2 | Operation failed because the number of requests exceeds the maximum value. (not supported currently)| diff --git a/en/application-dev/reference/apis/js-apis-power.md b/en/application-dev/reference/apis/js-apis-power.md index e8215f250a75223b6bb16024dea6a153adf71fd5..f98e56905a7671f4b0a0cb616d6ab64c198116f7 100644 --- a/en/application-dev/reference/apis/js-apis-power.md +++ b/en/application-dev/reference/apis/js-apis-power.md @@ -1,8 +1,9 @@ -# @ohos.power (System Power Management) +# @ohos.power (Power Manager) The **power** module provides APIs for rebooting and shutting down the system, as well as querying the screen status. -> **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. ## Modules to Import @@ -33,7 +34,7 @@ Shuts down the system. For details about the error codes, see [Power Manager Error Codes](../errorcodes/errorcode-power.md). -| Code | Error Message | +| ID | Error Message | |---------|---------| | 4900101 | Operation failed. Cannot connect to service.| @@ -69,7 +70,7 @@ Reboots the system. For details about the error codes, see [Power Manager Error Codes](../errorcodes/errorcode-power.md). -| Code | Error Message | +| ID | Error Message | |---------|---------| | 4900101 | Operation failed. Cannot connect to service.| @@ -95,7 +96,7 @@ Checks whether the current device is active. In the active state, the screen is For details about the error codes, see [Power Manager Error Codes](../errorcodes/errorcode-power.md). -| Code | Error Message | +| ID | Error Message | |---------|---------| | 4900101 | Operation failed. Cannot connect to service.| @@ -130,7 +131,7 @@ Wakes up a device. For details about the error codes, see [Power Manager Error Codes](../errorcodes/errorcode-power.md). -| Code | Error Message | +| ID | Error Message | |---------|---------| | 4900101 | Operation failed. Cannot connect to service.| @@ -158,7 +159,7 @@ Hibernates a device. For details about the error codes, see [Power Manager Error Codes](../errorcodes/errorcode-power.md). -| Code | Error Message | +| ID | Error Message | |---------|---------| | 4900101 | Operation failed. Cannot connect to service.| @@ -190,7 +191,7 @@ Obtains the power mode of this device. For details about the error codes, see [Power Manager Error Codes](../errorcodes/errorcode-power.md). -| Code | Error Message | +| ID | Error Message | |---------|---------| | 4900101 | Operation failed. Cannot connect to service.| @@ -228,7 +229,7 @@ Sets the power mode of this device. This API uses an asynchronous callback to re For details about the error codes, see [Power Manager Error Codes](../errorcodes/errorcode-power.md). -| Code | Error Message | +| ID | Error Message | |---------|---------| | 4900101 | Operation failed. Cannot connect to service.| @@ -272,7 +273,7 @@ Sets the power mode of this device. This API uses a promise to return the result For details about the error codes, see [Power Manager Error Codes](../errorcodes/errorcode-power.md). -| Code | Error Message | +| ID | Error Message | |---------|---------| | 4900101 | Operation failed. Cannot connect to service.| @@ -292,8 +293,7 @@ power.setPowerMode(power.DevicePowerMode.MODE_PERFORMANCE) rebootDevice(reason: string): void -> NOTE
-> This API is deprecated since API version 9. You are advised to use [power.reboot](#powerreboot9) instead. +> **NOTE**
This API is supported since API version 7 and is deprecated since API version 9. You are advised to use [power.reboot](#powerreboot9). The substitute API is available only for system applications. Reboots the system. @@ -317,8 +317,7 @@ power.rebootDevice('reboot_test'); isScreenOn(callback: AsyncCallback<boolean>): void -> NOTE
-> This API is deprecated since API version 9. You are advised to use [power.isActive](#powerisactive9) instead. +> **NOTE**
This API is deprecated since API version 9. You are advised to use [power.isActive](#powerisactive9). Checks the screen status of the current device. This API uses an asynchronous callback to return the result. @@ -328,7 +327,7 @@ Checks the screen status of the current device. This API uses an asynchronous ca | Name | Type | Mandatory| Description | | -------- | ---------------------------- | ---- | ------------------------------------------------------------ | -| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is the screen status obtained, where the value **true** indicates on and the value **false** indicates the opposite. Otherwise, **err** is an error object.| +| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is the screen status obtained, where the value **true** indicates on and the value **false** indicates off. Otherwise, **err** is an error object.| **Example** @@ -346,8 +345,7 @@ power.isScreenOn((err, data) => { isScreenOn(): Promise<boolean> -> NOTE
-> This API is deprecated since API version 9. You are advised to use [power.isActive](#powerisactive9) instead. +> **NOTE**
This API is deprecated since API version 9. You are advised to use [power.isActive](#powerisactive9). Checks the screen status of the current device. This API uses a promise to return the result. diff --git a/en/application-dev/reference/apis/js-apis-system-brightness.md b/en/application-dev/reference/apis/js-apis-system-brightness.md index 3cc0779edf610eb39cda868abc84d353c6b05dc6..8053c8f0c73d190d33e547ff9f0227df5c6db06a 100644 --- a/en/application-dev/reference/apis/js-apis-system-brightness.md +++ b/en/application-dev/reference/apis/js-apis-system-brightness.md @@ -3,7 +3,8 @@ The **brightness** module provides APIs for querying and adjusting the screen brightness and mode. > **NOTE** -> - The APIs of this module are no longer maintained since API version 7. It is recommended that you use [`@ohos.brightness`](js-apis-brightness.md) instead. +> +> - The APIs of this module are no longer maintained since API version 7. You are advised to use APIs of [`@ohos.brightness`](js-apis-brightness.md). The substitute APIs are available only for system applications. > - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version. diff --git a/en/application-dev/reference/apis/js-apis-telephony-data.md b/en/application-dev/reference/apis/js-apis-telephony-data.md index 7e244574143dd04bedd6c8f74a6206b0263f7584..a7a1338277a9b05840122488abb6553fd9b86e84 100644 --- a/en/application-dev/reference/apis/js-apis-telephony-data.md +++ b/en/application-dev/reference/apis/js-apis-telephony-data.md @@ -1,6 +1,6 @@ # @ohos.telephony.data (Cellular Data) -The cellular data module provides basic mobile data management functions. You can obtain and set the default slot of the SIM card used for mobile data, and obtain the uplink and downlink connection status of cellular data services and connection status of the packet switched (PS) domain. Besides, you can check whether cellular data services and data roaming are enabled. +The **data** module provides basic mobile data management functions. You can obtain and set the default slot of the SIM card used for mobile data, and obtain the uplink and downlink connection status of cellular data services and connection status of the packet switched (PS) domain. Besides, you can check whether cellular data services and data roaming are enabled. >**NOTE** > @@ -24,7 +24,7 @@ Obtains the default slot of the SIM card used for mobile data. This API uses an | Name | Type | Mandatory| Description | | -------- | ----------------------- | ---- | ------------------------------------------ | -| callback | AsyncCallback\ | Yes | Callback used to return the result.
**0**: card slot 1
**1**: card slot 2| +| callback | AsyncCallback\ | Yes | Callback used to return the result.
**0**: card slot 1.
**1**: card slot 2.| **Example** @@ -46,7 +46,7 @@ Obtains the default slot of the SIM card used for mobile data. This API uses a p | Type | Description | | ----------------- | ------------------------------------------------------------ | -| Promise\ | Promise used to return the result.
**0**: card slot 1
**1**: card slot 2| +| Promise\ | Promise used to return the result.
**0**: card slot 1.
**1**: card slot 2.| **Example** @@ -71,7 +71,7 @@ Obtains the default SIM card used for mobile data synchronously. | Type | Description | | ------ | -------------------------------------------------- | -| number | Card slot ID.
**0**: card slot 1
**1**: card slot 2| +| number | Card slot ID.
**0**: card slot 1.
**1**: card slot 2.| **Example** @@ -87,7 +87,7 @@ Sets the default slot of the SIM card used for mobile data. This API uses an asy **System API**: This is a system API. -**Required permission**: ohos.permission.SET_TELEPHONY_STATE +**Required permissions**: ohos.permission.SET_TELEPHONY_STATE **System capability**: SystemCapability.Telephony.CellularData @@ -95,7 +95,7 @@ Sets the default slot of the SIM card used for mobile data. This API uses an asy | Name | Type | Mandatory| Description | | -------- | --------------------- | ---- | ------------------------------------------------------------ | -| slotId | number | Yes | SIM card slot ID.
**0**: card slot 1
**1**: card slot 2
**-1**: Clears the default configuration.| +| slotId | number | Yes | SIM card slot ID.
**0**: card slot 1.
**1**: card slot 2.
**-1**: Clears the default configuration.| | callback | AsyncCallback\ | Yes | Callback used to return the result. | **Error codes** @@ -129,7 +129,7 @@ Sets the default slot of the SIM card used for mobile data. This API uses a prom **System API**: This is a system API. -**Required permission**: ohos.permission.SET_TELEPHONY_STATE +**Required permissions**: ohos.permission.SET_TELEPHONY_STATE **System capability**: SystemCapability.Telephony.CellularData @@ -137,7 +137,7 @@ Sets the default slot of the SIM card used for mobile data. This API uses a prom | Name| Type | Mandatory| Description | | ------ | ------ | ---- | ------------------------------------------------------------ | -| slotId | number | Yes | SIM card slot ID.
**0**: card slot 1
**1**: card slot 2
**-1**: Clears the default configuration.| +| slotId | number | Yes | SIM card slot ID.
**0**: card slot 1.
**1**: card slot 2.
**-1**: Clears the default configuration.| **Return value** @@ -356,7 +356,7 @@ Checks whether roaming is enabled for the cellular data service. This API uses a | Name | Type | Mandatory| Description | | -------- | ------------------------ | ---- | ------------------------------------------------------------ | -| slotId | number | Yes | Card slot ID.
**0**: card slot 1
**1**: card slot 2 | +| slotId | number | Yes | Card slot ID.
**0**: card slot 1.
**1**: card slot 2. | | callback | AsyncCallback\ | Yes | Callback used to return the result.
**true**: Roaming is enabled for the cellular data service.
**false**: Roaming is disabled for the cellular data service.| **Error codes** @@ -394,7 +394,7 @@ Checks whether roaming is enabled for the cellular data service. This API uses a | Name| Type | Mandatory| Description | | ------ | ------ | ---- | ---------------------------------------- | -| slotId | number | Yes | Card slot ID.
**0**: card slot 1
**1**: card slot 2| +| slotId | number | Yes | Card slot ID.
**0**: card slot 1.
**1**: card slot 2.| **Return value** @@ -434,7 +434,7 @@ Enables the cellular data service. This API uses an asynchronous callback to ret **System API**: This is a system API. -**Required permission**: ohos.permission.SET_TELEPHONY_STATE +**Required permissions**: ohos.permission.SET_TELEPHONY_STATE **System capability**: SystemCapability.Telephony.CellularData @@ -473,7 +473,7 @@ Enables the cellular data service. This API uses a promise to return the result. **System API**: This is a system API. -**Required permission**: ohos.permission.SET_TELEPHONY_STATE +**Required permissions**: ohos.permission.SET_TELEPHONY_STATE **System capability**: SystemCapability.Telephony.CellularData @@ -515,7 +515,7 @@ Disables the cellular data service. This API uses an asynchronous callback to re **System API**: This is a system API. -**Required permission**: ohos.permission.SET_TELEPHONY_STATE +**Required permissions**: ohos.permission.SET_TELEPHONY_STATE **System capability**: SystemCapability.Telephony.CellularData @@ -554,7 +554,7 @@ Disables the cellular data service. This API uses a promise to return the result **System API**: This is a system API. -**Required permission**: ohos.permission.SET_TELEPHONY_STATE +**Required permissions**: ohos.permission.SET_TELEPHONY_STATE **System capability**: SystemCapability.Telephony.CellularData @@ -596,7 +596,7 @@ Enables the cellular data roaming service. This API uses an asynchronous callbac **System API**: This is a system API. -**Required permission**: ohos.permission.SET_TELEPHONY_STATE +**Required permissions**: ohos.permission.SET_TELEPHONY_STATE **System capability**: SystemCapability.Telephony.CellularData @@ -604,7 +604,7 @@ Enables the cellular data roaming service. This API uses an asynchronous callbac | Name | Type | Mandatory| Description | | -------- | --------------------- | ---- | ---------------------------------------- | -| slotId | number | Yes | Card slot ID.
**0**: card slot 1
**1**: card slot 2| +| slotId | number | Yes | Card slot ID.
**0**: card slot 1.
**1**: card slot 2.| | callback | AsyncCallback\ | Yes | Callback used to return the result. | **Error codes** @@ -636,7 +636,7 @@ Enables the cellular data roaming service. This API uses a promise to return the **System API**: This is a system API. -**Required permission**: ohos.permission.SET_TELEPHONY_STATE +**Required permissions**: ohos.permission.SET_TELEPHONY_STATE **System capability**: SystemCapability.Telephony.CellularData @@ -644,7 +644,7 @@ Enables the cellular data roaming service. This API uses a promise to return the | Name| Type | Mandatory| Description | | ------ | ------ | ---- | ---------------------------------------- | -| slotId | number | Yes | Card slot ID.
**0**: card slot 1
**1**: card slot 2| +| slotId | number | Yes | Card slot ID.
**0**: card slot 1.
**1**: card slot 2.| **Return value** @@ -684,7 +684,7 @@ Disables the cellular data roaming service. This API uses an asynchronous callba **System API**: This is a system API. -**Required permission**: ohos.permission.SET_TELEPHONY_STATE +**Required permissions**: ohos.permission.SET_TELEPHONY_STATE **System capability**: SystemCapability.Telephony.CellularData @@ -692,7 +692,7 @@ Disables the cellular data roaming service. This API uses an asynchronous callba | Name | Type | Mandatory| Description | | -------- | --------------------- | ---- | ---------------------------------------- | -| slotId | number | Yes | Card slot ID.
**0**: card slot 1
**1**: card slot 2| +| slotId | number | Yes | Card slot ID.
**0**: card slot 1.
**1**: card slot 2.| | callback | AsyncCallback\ | Yes | Callback used to return the result. | **Error codes** @@ -724,7 +724,7 @@ Disables the cellular data roaming service. This API uses a promise to return th **System API**: This is a system API. -**Required permission**: ohos.permission.SET_TELEPHONY_STATE +**Required permissions**: ohos.permission.SET_TELEPHONY_STATE **System capability**: SystemCapability.Telephony.CellularData @@ -732,7 +732,7 @@ Disables the cellular data roaming service. This API uses a promise to return th | Name| Type | Mandatory| Description | | ------ | ------ | ---- | ---------------------------------------- | -| slotId | number | Yes | Card slot ID.
**0**: card slot 1
**1**: card slot 2| +| slotId | number | Yes | Card slot ID.
**0**: card slot 1.
**1**: card slot 2.| **Return value** diff --git a/en/application-dev/reference/errorcodes/Readme-EN.md b/en/application-dev/reference/errorcodes/Readme-EN.md index 32a9f00da8e8b45373629f13cadd7b9414855591..a9e53ed27e739a1accada2bfd497a7966003ad31 100644 --- a/en/application-dev/reference/errorcodes/Readme-EN.md +++ b/en/application-dev/reference/errorcodes/Readme-EN.md @@ -56,6 +56,7 @@ - [Ethernet Connection Error Codes](errorcode-net-ethernet.md) - [Network Sharing Error Codes](errorcode-net-sharing.md) - [Policy Management Error Codes](errorcode-net-policy.md) + - [mDNS Error Codes](errorcode-net-mdns.md) - Connectivity - [Bluetooth Error Codes](errorcode-bluetoothManager.md) - [Wi-Fi Error Codes](errorcode-wifi.md) diff --git a/en/application-dev/reference/errorcodes/errorcode-net-mdns.md b/en/application-dev/reference/errorcodes/errorcode-net-mdns.md new file mode 100644 index 0000000000000000000000000000000000000000..c17476575797e590821efa60526c0fbadcd39101 --- /dev/null +++ b/en/application-dev/reference/errorcodes/errorcode-net-mdns.md @@ -0,0 +1,117 @@ +# mDNS Error Codes + +> **NOTE** +> +> This topic describes only module-specific error codes. For details about universal error codes, see [Universal Error Codes](errorcode-universal.md). + +## 2100002 Service Connection Failure + +**Error Message** + +Operation failed. Cannot connect to service. + +**Description** + +This error code is reported if a service connection failure occurs. + +**Possible Causes** + +The service is abnormal. + +**Procedure** + +Check whether system services are running properly. + +## 2100003 System Internal Error + +**Error Message** + +System internal error. + +**Description** + +This error code is reported if a system internal error occurs. + +**Possible Causes** + +1. The memory is abnormal. + +2. A null pointer is present. + +**Procedure** + +1. Check whether the memory space is sufficient. If not, clear the memory and try again. + +2. Check whether the system is normal. If not, try again later or restart the device. + +## 2204003 Repeated Registration + +**Error Message** + +Callback duplicated. + +**Description** + +The callback already exists. + +**Possible Causes** + +An mDNS service with the same name and type is repeatedly registered. + +**Procedure** + +Check whether the mDNS service to be registered already exists. + +## 2204008 Service Deletion Failure + +**Error Message** + +Service instance duplicated. + +**Description** + +The service to be removed does not exist. + +**Possible Causes** + +The service has been deleted. + +**Procedure** + +Check whether the mDNS service to be deleted exists. + +## 2204010 Message Sending Failure + +**Error Message** + +Send packet failed. + +**Description** + +Messages fail to be sent through an mDNS service. + +**Possible Causes** + +The mDNS service does not exist on the LAN. + +**Procedure** + +Check whether the target mDNS service exists on the LAN. + +## 2204006 Service Resolution Timeout + +**Error Message** + +Request timeout. + +**Description** + +mDNS services of the specified type fail to be resolved. + +**Possible Causes** + +mDNS services of the specified type do not exist on the LAN. + +**Procedure** + +Check whether mDNS services of the specified type exist on the LAN. diff --git a/en/device-dev/subsystems/Readme-EN.md b/en/device-dev/subsystems/Readme-EN.md index 48abe9e925388d38780f85266985ff7532988f89..63dfb30426ef5a4e92d650e884115884a05eddbf 100644 --- a/en/device-dev/subsystems/Readme-EN.md +++ b/en/device-dev/subsystems/Readme-EN.md @@ -90,14 +90,13 @@ - [HiTraceChain Development](subsys-dfx-hitracechain.md) - [HiTraceMeter Development](subsys-dfx-hitracemeter.md) - [HiCollie Development](subsys-dfx-hicollie.md) - - HiSysEvent Development + - HiSysEvent - [HiSysEvent Overview](subsys-dfx-hisysevent-overview.md) - [HiSysEvent Logging Configuration](subsys-dfx-hisysevent-logging-config.md) - [HiSysEvent Logging](subsys-dfx-hisysevent-logging.md) - [HiSysEvent Listening](subsys-dfx-hisysevent-listening.md) - [HiSysEvent Query](subsys-dfx-hisysevent-query.md) - [HiSysEvent Tool Usage](subsys-dfx-hisysevent-tool.md) - - [HiDumper Development](subsys-dfx-hidumper.md) - [HiChecker Development](subsys-dfx-hichecker.md) - [FaultLogger Development](subsys-dfx-faultlogger.md) - [Hiview Development](subsys-dfx-hiview.md) @@ -105,6 +104,7 @@ - [bytrace](subsys-toolchain-bytrace-guide.md) - [hdc](subsys-toolchain-hdc-guide.md) - [hiperf](subsys-toolchain-hiperf.md) + - [HiDumper](subsys-dfx-hidumper.md) - Power Management - Display Management - [System Brightness Customization](subsys-power-brightness-customization.md) diff --git a/en/device-dev/subsystems/figures/nnrt_arch_diagram.png b/en/device-dev/subsystems/figures/nnrt_arch_diagram.png new file mode 100644 index 0000000000000000000000000000000000000000..8a4a218f519c5707fbb2d5724b6c1a731d76f911 Binary files /dev/null and b/en/device-dev/subsystems/figures/nnrt_arch_diagram.png differ diff --git a/en/device-dev/subsystems/figures/nnrt_dev_flow.png b/en/device-dev/subsystems/figures/nnrt_dev_flow.png new file mode 100644 index 0000000000000000000000000000000000000000..612ae5fe5abfb3df5936c314672cf1877ee5404d Binary files /dev/null and b/en/device-dev/subsystems/figures/nnrt_dev_flow.png differ diff --git a/en/device-dev/subsystems/subsys-ai-nnrt-guide.md b/en/device-dev/subsystems/subsys-ai-nnrt-guide.md new file mode 100644 index 0000000000000000000000000000000000000000..c0d4a951d49e583bbeecbafcc844f9089e8e2a9b --- /dev/null +++ b/en/device-dev/subsystems/subsys-ai-nnrt-guide.md @@ -0,0 +1,407 @@ +# NNRt Development + +## Overview + +### Function Introduction + +Neural Network Runtime (NNRt) functions as a bridge to connect the upper-layer AI inference framework and bottom-layer acceleration chips, implementing cross-chip inference computing of AI models. + +With the open APIs provided by NNRt, chip vendors can connect their dedicated acceleration chips to NNRt to access the OpenHarmony ecosystem. + +### Basic Concepts +Before you get started, it would be helpful for you to have a basic understanding of the following concepts: + +- Hardware Device Interface (HDI): defines APIs for cross-process communication between services in OpenHarmony. +- Interface Description Language (IDL): defines the HDI language format. + +### Constraints +- System version: OpenHarmony trunk version. +- Development environment: Ubuntu 18.04 or later. +- Access device: a chip with AI computing capabilities. + +### Working Principles +NNRt connects to device chips through HDIs, which implement cross-process communication between services. + +**Figure 1** NNRt architecture + +![NNRt architecture](./figures/nnrt_arch_diagram.png) + +The NNRt architecture consists of three layers: AI applications at the application layer, AI inference framework and NNRt at the system layer, and device services at the chip layer. To use a dedicated acceleration chip model for inference, an AI application needs to call the dedicated acceleration chip at the bottom layer through the AI inference framework and NNRt. NNRt is responsible for adapting to various dedicated acceleration chips at the bottom layer. It opens standard and unified HDIs for various chips to access the OpenHarmony ecosystem. + +During program running, the AI application, AI inference framework, and NNRt reside in the user process, and the underlying device services reside in the service process. NNRt implements the HDI client and the service side implements HDI Service to fulfill cross-process communication. + +## How to Develop + +### Application Scenario +Suppose you are connecting an AI acceleration chip, for example, RK3568, to NNRt. The following describes how to connect the RK3568 chip to NNRt through the HDI to implement AI model inference. +> **NOTE**
In this application scenario, the connection of the RK3568 chip to NNRt is implemented by utilizing the CPU operator of MindSpore Lite, instead of writing the CPU driver. This is the reason why the following development procedure depends on the dynamic library and header file of MindSpore Lite. In practice, the development does not depend on any library or header file of MindSpore Lite. + +### Development Flowchart +The following figure shows the process of connecting a dedicated acceleration chip to NNRt. + +**Figure 2** NNRt development flowchart + +![NNRt development flowchart](./figures/nnrt_dev_flow.png) + +### Development Procedure + +To connect the acceleration chip to NNRt, perform the development procedure below. + +#### Generating the HDI Header File + +Download the OpenHarmony source code from the open source community, build the `drivers_interface` component, and generate the HDI header file. + +1. [Download the source code](../get-code/sourcecode-acquire.md). + +2. Build the IDL file of the HDI. + ```shell + ./build.sh --product-name productname –ccache --build-target drivers_interface_nnrt + ``` + > **NOTE**
**productname** indicates the product name. In this example, the product name is **RK3568**. + + When the build is complete, the HDI header file is generated in `out/rk3568/gen/drivers/interface/nnrt`. The default programming language is C++. To generate a header file for the C programming language, run the following command to set the `language` field in the `drivers/interface/nnrt/v1_0/BUILD.gn` file before starting the build: + + ```shell + language = "c" + ``` + + The directory of the generated header file is as follows: + ```text + out/rk3568/gen/drivers/interface/nnrt + └── v1_0 + ├── drivers_interface_nnrt__libnnrt_proxy_1.0_external_deps_temp.json + ├── drivers_interface_nnrt__libnnrt_stub_1.0_external_deps_temp.json + ├── innrt_device.h # Header file of the HDI + ├── iprepared_model.h # Header file of the AI model + ├── libnnrt_proxy_1.0__notice.d + ├── libnnrt_stub_1.0__notice.d + ├── model_types.cpp # Implementation file for AI model structure definition + ├── model_types.h # Header file for AI model structure definition + ├── nnrt_device_driver.cpp # Device driver implementation example + ├── nnrt_device_proxy.cpp + ├── nnrt_device_proxy.h + ├── nnrt_device_service.cpp # Implementation file for device services + ├── nnrt_device_service.h # Header file for device services + ├── nnrt_device_stub.cpp + ├── nnrt_device_stub.h + ├── nnrt_types.cpp # Implementation file for data type definition + ├── nnrt_types.h # Header file for data type definition + ├── node_attr_types.cpp # Implementation file for AI model operator attribute definition + ├── node_attr_types.h # Header file for AI model operator attribute definition + ├── prepared_model_proxy.cpp + ├── prepared_model_proxy.h + ├── prepared_model_service.cpp # Implementation file for AI model services + ├── prepared_model_service.h # Header file for AI model services + ├── prepared_model_stub.cpp + └── prepared_model_stub.h + ``` + +#### Implementing the HDI Service + +1. Create a development directory in `drivers/peripheral`. The structure of the development directory is as follows: + ```text + drivers/peripheral/nnrt + ├── BUILD.gn # Code build script + ├── bundle.json + └── hdi_cpu_service # Customized directory + ├── BUILD.gn # Code build script + ├── include + │ ├── nnrt_device_service.h # Header file for device services + │ ├── node_functions.h # Optional, depending on the actual implementation + │ ├── node_registry.h # Optional, depending on the actual implementation + │ └── prepared_model_service.h # Header file for AI model services + └── src + ├── nnrt_device_driver.cpp # Implementation file for the device driver + ├── nnrt_device_service.cpp # Implementation file for device services + ├── nnrt_device_stub.cpp # Optional, depending on the actual implementation + ├── node_attr_types.cpp # Optional, depending on the actual implementation + ├── node_functions.cpp # Optional, depending on the actual implementation + ├── node_registry.cpp # Optional, depending on the actual implementation + └── prepared_model_service.cpp # Implementation file for AI model services + ``` + +2. Implement the device driver. Unless otherwise required, you can directly use the `nnrt_device_driver.cpp` file generated in step 1. + +3. Implement service APIs. For details, see the `nnrt_device_service.cpp` and `prepared_model_service.cpp` implementation files. For details about the API definition, see [NNRt HDI Definitions](https://gitee.com/openharmony/drivers_interface/tree/master/nnrt). + +4. Build the implementation files for device drivers and services as shared libraries. + + Create the `BUILD.gn` file with the following content in `drivers/peripheral/nnrt/hdi_cpu_service/`. For details about how to set related parameters, see [Compilation and Building](https://gitee.com/openharmony/build). + + ```shell + import("//build/ohos.gni") + import("//drivers/hdf_core/adapter/uhdf2/uhdf.gni") + + ohos_shared_library("libnnrt_service_1.0") { + include_dirs = [] + sources = [ + "src/nnrt_device_service.cpp", + "src/prepared_model_service.cpp", + "src/node_registry.cpp", + "src/node_functions.cpp", + "src/node_attr_types.cpp" + ] + public_deps = [ "//drivers/interface/nnrt/v1_0:nnrt_idl_headers" ] + external_deps = [ + "hdf_core:libhdf_utils", + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_single", + "c_utils:utils", + ] + + install_images = [ chipset_base_dir ] + subsystem_name = "hdf" + part_name = "drivers_peripheral_nnrt" + } + + ohos_shared_library("libnnrt_driver") { + include_dirs = [] + sources = [ "src/nnr_device_driver.cpp" ] + deps = [ "//drivers/peripheral/nnrt/hdi_cpu_service:libnnrt_service_1.0" ] + + external_deps = [ + "hdf_core:libhdf_host", + "hdf_core:libhdf_ipc_adapter", + "hdf_core:libhdf_utils", + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_single", + "c_utils:utils", + ] + + install_images = [ chipset_base_dir ] + subsystem_name = "hdf" + part_name = "drivers_peripheral_nnrt" + } + + group("hdf_nnrt_service") { + deps = [ + ":libnnrt_driver", + ":libnnrt_service_1.0", + ] + } + ``` + + Add `group("hdf_nnrt_service")` to the `drivers/peripheral/nnrt/BUILD.gn` file so that it can be referenced at a higher directory level. + ```shell + if (defined(ohos_lite)) { + group("nnrt_entry") { + deps = [ ] + } + } else { + group("nnrt_entry") { + deps = [ + "./hdi_cpu_service:hdf_nnrt_service", + ] + } + } + ``` + + Create the `drivers/peripheral/nnrt/bundle.json` file to define the new `drivers_peripheral_nnrt` component. + ```json + { + "name": "drivers_peripheral_nnrt", + "description": "Neural network runtime device driver", + "version": "3.2", + "license": "Apache License 2.0", + "component": { + "name": "drivers_peripheral_nnrt", + "subsystem": "hdf", + "syscap": [""], + "adapter_system_type": ["standard"], + "rom": "1024KB", + "ram": "2048KB", + "deps": { + "components": [ + "ipc", + "hdf_core", + "hiviewdfx_hilog_native", + "c_utils" + ], + "third_part": [ + "bounds_checking_function" + ] + }, + "build": { + "sub_component": [ + "//drivers/peripheral/nnrt:nnrt_entry" + ], + "test": [ + ], + "inner_kits": [ + ] + } + } + } + ``` + +#### Declaring the HDI Service + + In the uhdf directory, declare the user-mode driver and services in the **.hcs** file of the corresponding product. For example, for the RK3568 chip, add the following configuration to the `vendor/hihope/rk3568/hdf_config/uhdf/device_info.hcs` file: + ```text + nnrt :: host { + hostName = "nnrt_host"; + priority = 50; + uid = ""; + gid = ""; + caps = ["DAC_OVERRIDE", "DAC_READ_SEARCH"]; + nnrt_device :: device { + device0 :: deviceNode { + policy = 2; + priority = 100; + moduleName = "libnnrt_driver.z.so"; + serviceName = "nnrt_device_service"; + } + } + } + ``` +> **NOTE**
After modifying the `.hcs` file, you need to delete the `out` directory and build the file again for the modification to take effect. + +#### Configuring the User ID and Group ID of the Host Process + In the scenario of creating an nnrt_host process, you need to configure the user ID and group ID of the corresponding process. The user ID is configured in the `base/startup/init/services/etc/passwd` file, and the group ID is configured in the `base/startup/init/services/etc/group` file. + ```text + # Add the user ID in base/startup/init/services/etc/passwd. + nnrt_host:x:3311:3311:::/bin/false + + # Add the group ID in base/startup/init/services/etc/group. + nnrt_host:x:3311: + ``` + +#### Configuring SELinux + +The SELinux feature has been enabled for the OpenHarmony. You need to configure SELinux rules for the new processes and services so that they can run the host process to access certain resources and release HDI services. + +1. Configure the security context of the **nnrt_host** process in the `base/security/selinux/sepolicy/ohos_policy/drivers/adapter/vendor/type.te` file. + ```text + # Add the security context configuration. + type nnrt_host, hdfdomain, domain; + ``` + > **NOTE**
In the preceding command, **nnrt_host** indicates the process name previously configured. + +2. Configure access permissions because SELinux uses the trustlist access permission mechanism. Upon service startup, run the `dmesg` command to view the AVC alarm, +which provides a list of missing permissions. For details about the SELinux configuration, see [security_selinux] (https://gitee.com/openharmony/security_selinux/blob/master/README-en.md). + ```shell + hdc_std shell + dmesg | grep nnrt + ``` + +3. Create the `nnrt_host.te` file. + ```shell + # Create the nnrt folder. + mkdir base/security/selinux/sepolicy/ohos_policy/drivers/peripheral/nnrt + + # Create the vendor folder. + mkdir base/security/selinux/sepolicy/ohos_policy/drivers/peripheral/nnrt/vendor + + # Create the nnrt_host.te file. + touch base/security/selinux/sepolicy/ohos_policy/drivers/peripheral/nnrt/vendor/nnrt_host.te + ``` + +4. Add the required permissions to the `nnrt_host.te` file. For example: + ```text + allow nnrt_host dev_hdf_kevent:chr_file { ioctl }; + allow nnrt_host hilog_param:file { read }; + allow nnrt_host sh:binder { transfer }; + allow nnrt_host dev_ashmem_file:chr_file { open }; + allow sh nnrt_host:fd { use }; + ``` + +#### Configuring the Component Build Entry +Access the `chipset_common.json` file. +```shell +vim //productdefine/common/inherit/chipset_common.json +``` +Add the following to `"subsystems"`, `"subsystem":"hdf"`, `"components"`: +```shell +{ + "component": "drivers_peripheral_foo", + "features": [] +} +``` + +#### Deleting the out Directory and Building the Entire System +```shell +# Delete the out directory. +rm -rf ./out + +# Build the entire system. +./build.sh --product-name rk3568 –ccache --jobs=4 +``` + + +### Commissioning and Verification +On completion of service development, you can use XTS to verify its basic functions and compatibility. + +1. Build the **hats** test cases of NNRt in the `test/xts/hats/hdf/nnrt` directory. + ```shell + # Go to the hats directory. + cd test/xts/hats + + # Build the hats test cases. + ./build.sh suite=hats system_size=standard --product-name rk3568 + + # Return to the root directory. + cd - + ``` + The hats test cases are exported to `out/rk3568/suites/hats/testcases/HatsHdfNnrtFunctionTest` in the relative code root directory. + +2. Push the test cases to the device. + ```shell + # Push the executable file of test cases to the device. In this example, the executable file is HatsHdfNnrtFunctionTest. + hdc_std file send out/rk3568/suites/hats/testcases/HartsHdfNnrtFunctionTest /data/local/tmp/ + + # Grant required permissions to the executable file of test cases. + hdc_std shell "chmod +x /data/local/tmp/HatsHdfNnrtFunctionTest" + ``` + +3. Execute the test cases and view the result. + ```shell + # Execute the test cases. + hdc_std shell "/data/local/tmp/HatsHdfNnrtFunctionTest" + ``` + + The test report below shows that all 47 test cases are successful, indicating that the service has passed the compatibility test. + ```text + ... + [----------] Global test environment tear-down + Gtest xml output finished + [==========] 47 tests from 3 test suites ran. (515 ms total) + [ PASSED ] 47 tests. + ``` + +### Development Example +For the complete demo code, see [NNRt Service Implementation Example](https://gitee.com/openharmony/ai_neural_network_runtime/tree/master/example/drivers). + +1. Copy the `example/driver/nnrt` directory to `drivers/peripheral`. + ```shell + cp -r example/driver/nnrt drivers/peripheral + ``` + +2. Add the `bundle.json` file to `drivers/peripheral/nnrt`. For details about the `bundle.json` file, see [Development Procedure](#development-procedure). + +3. Add the dependency files of MindSpore Lite because the demo depends on the CPU operator of MindSpore Lite. + - Download the header file of [MindSpore Lite 1.5.0](https://ms-release.obs.cn-north-4.myhuaweicloud.com/1.5.0/MindSpore/lite/release/linux/mindspore-lite-1.5.0-linux-x64.tar.gz). + 1. Create the `mindspore` directory in `drivers/peripheral/nnrt`. + ```shell + mkdir drivers/peripheral/nnrt/mindspore + ``` + 2. Decompress the `mindspore-lite-1.5.0-linux-x64.tar.gz` file, and copy the `runtime/include` directory to `drivers/peripheral/nnrt/mindspore`. + 3. Create and copy the `schema` file of MindSpore Lite. + ```shell + # Create the mindspore_schema directory. + mkdir drivers/peripheral/nnrt/hdi_cpu_service/include/mindspore_schema + + # Copy the schema file of MindSpore Lite. + cp third_party/mindspore/mindspore/lite/schema/* drivers/peripheral/nnrt/hdi_cpu_service/include/mindspore_schema/ + ``` + 4. Build the dynamic library of MindSpore Lite, and put the dynamic library in the `mindspore`directory. + ```shell + # Build the dynamic library of MindSpore Lite. + ./build.sh --product-name rk3568 -ccaache --jobs 4 --build-target mindspore_lib + + # Create the mindspore subdirectory. + mkdir drivers/peripheral/nnrt/mindspore/mindspore + + # Copy the dynamic library to drivers/peripheral/nnrt/mindspore/mindspore. + cp out/rk3568/package/phone/system/lib/libmindspore-lite.huawei.so drivers/peripheral/nnrt/mindspore/mindspore/ + ``` +4. Follow the [development procedure](#development-procedure) to complete other configurations. diff --git a/en/device-dev/subsystems/subsys-dfx-hicollie.md b/en/device-dev/subsystems/subsys-dfx-hicollie.md index 90bb652a9a0f678b8a413b187bfd3bbd41d13e26..321bc54040002845d5c94b3d1964af165526d68b 100644 --- a/en/device-dev/subsystems/subsys-dfx-hicollie.md +++ b/en/device-dev/subsystems/subsys-dfx-hicollie.md @@ -1,185 +1,101 @@ -# HiCollie Development +# HiCollie Development -## Overview -HiCollie provides the software watchdog function. It provides a unified framework for fault detection and fault log generation to help you locate software timeout faults resulting from system service deadlock, application main thread blocking, and service process timeout. - -## Available APIs - -**Table 1** Description of C++ APIs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Class

-

API

-

Description

-

XCollieChecker

-

virtual void CheckBlock()

-

Provides the callback of the suspension detection result.

-

Input arguments: none

-

Output arguments: none

-

Return value: none

-

XCollieChecker

-

virtual void CheckThreadBlock()

-

Provides the callback of the thread suspension detection result.

-

Input arguments: none

-

Output arguments: none

-

Return value: none

-

XCollie

-

void RegisterXCollieChecker(const sptr<XCollieChecker> &checker, unsigned int type)

-

Registers the callback of the thread suspension detection result.

-

Input arguments:

-
  • checker: Indicates the pointer to the XCollieChecker instance.
  • type: Indicates the suspension detection type. Set it to XCOLLIE_THREAD.
-

Output arguments: none

-

Return value: none

-

XCollie

-

int SetTimer(const std::string &name, unsigned int timeout, std::function<void (void *)> func, void *arg, unsigned int flag)

-

Adds timers.

-

Input arguments:

-
  • name: Indicates the timer name.
  • timeout: Indicates the timeout duration, in seconds.
  • func: Indicates the timeout callback.
  • arg: Indicates the pointer to the timeout callback.
  • flag: Indicates the timer operation type.

    XCOLLIE_FLAG_DEFAULT // Indicates the default flag, which is the combination of the other three options.

    -

    XCOLLIE_FLAG_NOOP // Calls only the timeout callback.

    -

    XCOLLIE_FLAG_LOG // Generates a timeout fault log.

    -

    XCOLLIE_FLAG_RECOVERY // Exits the process.

    -
-

Output arguments: none

-

Return value: Returns the timer ID if the operation is successful; returns -1 otherwise.

-

XCollie

-

bool UpdateTimer(int id, unsigned int timeout)

-

Updates timers.

-

Input arguments:

-
  • id: Indicates the timer ID.
  • timeout: Indicates the timeout duration, in seconds.
-

Output arguments: none

-

Return value: Returns true if the operation is successful; returns false otherwise.

-

XCollie

-

void CancelTimer(int id)

-

Cancels timers.

-

Input arguments:

-

id: Indicates the timer ID.

-

Output arguments: none

-

Return value: none

-
- -## Example - -Print logs. - -``` -timeout: TimeoutTimer start at 1611040305 to check 1s ago - -----------StacktraceCatcher CurrentTime:2021-01-19 15:11:45 Unexecuted(-1)(LogType:Stacktrace Pid:27689 Process:XCollieTimeoutModuleTest)---------- - - ------ pid 27689 at 2021-01-19 15:11:45 ----- -Cmd line: ./XCollieTimeoutModuleTest -ABI: 'arm64' - -"XCollieTimeoutM" sysTid=27689 - #01 pc 00000000000174cc /data/test/XCollieTimeoutModuleTest -``` - -## How to Develop - -### C++ - -### Thread Suspension Monitoring - -This function requires you to implement two callback functions: **CheckBlock** and **CheckThreadBlock** of the **XCollieChecker** class. After the callbacks are implemented, you need to use the **RegisterXCollieChecker** function of the **XCollie** class to register their instances. The suspension monitoring thread periodically executes all successfully registered callbacks, checks the thread logic completion flag, and determines whether the service logic of any registered thread is suspended. - -1. Develop the source code. - - Include the **xcollie** header file in the source file. - - ``` - #include "xcollie.h" - ``` - - Add the following code to the service code: - - ``` - void MyXCollieChecker::CheckLock() - { - /* time consuming job */ - } - - void MyXCollieChecker::CheckThreadBlock() - { - /* time consuming job */ - } - - sptr checker = new MyXCollieChecker("MyXCollieChecker"); - XCollie::GetInstance().RegisterXCollieChecker(checker, - (XCOLLIE_LOCK | XCOLLIE_THREAD)); - ... - ``` - -2. Configure compilation information. Specifically, add the subsystem SDK dependency to **BUILD.gn**. - - ``` - external_deps = [ "hiviewdfx:libxcollie" ] - ``` - - -### Timeout Monitoring - -You can add a maximum of 128 timers for a single process by using the **SetTimer** function. Adding timers will fail if the number of timers has reached the upper limit. - -1. Develop the source code. - - Include the **xcollie** header file in the source file. - - ``` - #include "xcollie.h" - ``` - - Add the code to add, update, and cancel timers. - - ``` - std::function callback = [](void *args) - { - /* dump helpful information */ - }; - - int id = XCollie::GetInstance().SetTimer("MyXCollieTimer", 10, callback ,nullptr, XCOLLIE_FLAG_LOG); - /* time consuming job */ - XCollie::GetInstance().UpdateTimer(id, 5); - /* time consuming job */ - XCollie::GetInstance().CancelTimer(id); - ... - ``` +## Overview -2. Configure compilation information. Specifically, add the subsystem SDK dependency to **BUILD.gn**. - - ``` - external_deps = [ "hiviewdfx:libxcollie" ] - ``` +HiCollie provides the software watchdog function. It provides a unified framework for fault detection and fault log generation to help you locate software timeout faults resulting from system service deadlock, application main thread blocking, and service process timeout. +## Available APIs + + **Table 1** Description of XCollieChecker APIs + +| API| Description| +| -------- | -------- | +| virtual void CheckBlock() | Provides the callback of the suspension detection result.
Input arguments: none
Output arguments: none
Return value: none| +| virtual void CheckThreadBlock() | Provides the callback of the thread suspension detection result.
Input arguments: none
Output arguments: none
Return value: none| + + + **Table 2** Description of XCollie APIs + +| API| Description| +| -------- | -------- | +| void RegisterXCollieChecker(const sptr<XCollieChecker> &checker, unsigned int type) | Registers the callback of the thread suspension detection result.
Input arguments:
- **checker**: pointer to the XCollieChecker instance.
- **type**: suspension detection type. Set it to **XCOLLIE_THREAD**.
Output arguments: none
Return value: none| +| int SetTimer(const std::string &name, unsigned int timeout, std::function<void(void*)> func, void *arg, unsigned int flag) | Adds timers.
Input arguments:
- **name**: timer name.
- **timeout**: timeout duration, in seconds.
- **func**: timeout callback.
- **arg**: pointer to the timeout callback.
- **flag**: timer operation type.
- **XCOLLIE_FLAG_DEFAULT**: default flag, which is the combination of the other three options.
- **XCOLLIE_FLAG_NOOP**: Calls only the timeout callback.
- **XCOLLIE_FLAG_LOG**: Generates a timeout fault log.
- **XCOLLIE_FLAG_RECOVERY**: Exits the process.
Output arguments: none
Return value: timer ID if the operation is successful; **-1** otherwise.| +| bool UpdateTimer(int id, unsigned int timeout) | Updates timers.
Input arguments:
- **id**: timer ID.
- **timeout**: timeout duration, in seconds.
Output arguments: none
Return value: **true** if the operation is successful; **false** otherwise.| +| void CancelTimer(int id) | Cancels a timer.
Input arguments:
- **id**: timer ID.
Output arguments: none
Return value: none| + + +## How to Develop + + +### Thread Suspension Monitoring + +This function requires you to implement two callback functions: **CheckBlock** and **CheckThreadBlock** of the **XCollieChecker** class. After the callbacks are implemented, you need to use the **RegisterXCollieChecker** function of the **XCollie** class to register their instances. The suspension monitoring thread periodically executes all successfully registered callbacks, checks the thread logic completion flag, and determines whether the service logic of any registered thread is suspended. + +1. Develop the source code. + Include the **xcollie** header file in the source file. + + ``` + #include "xcollie.h" + ``` + + Add the following code to the service code: + + + ``` + void MyXCollieChecker::CheckLock() + { + /* time consuming job */ + } + + void MyXCollieChecker::CheckThreadBlock() + { + /* time consuming job */ + } + + sptr checker = new MyXCollieChecker("MyXCollieChecker"); + XCollie::GetInstance().RegisterXCollieChecker(checker, + (XCOLLIE_LOCK | XCOLLIE_THREAD)); + ...... + ``` + +2. Configure compilation information. Specifically, add the subsystem SDK dependency to **BUILD.gn**. + + ``` + external_deps = [ "hiviewdfx:libxcollie" ] + ``` + + +### Timeout Monitoring + +You can add a maximum of 128 timers for a single process by using the **SetTimer** function. Adding timers will fail if the number of timers has reached the upper limit. + +1. Develop the source code. + Include the **xcollie** header file in the source file. + + ``` + #include "xcollie.h" + ``` + + Add the code to add, update, and cancel timers. + + ``` + std::function callback = [](void *args) + { + /* dump helpful information */ + }; + + int id = XCollie::GetInstance().SetTimer("MyXCollieTimer", 10, callback ,nullptr, XCOLLIE_FLAG_LOG); + /* time consuming job */ + XCollie::GetInstance().UpdateTimer(id, 5); + /* time consuming job */ + XCollie::GetInstance().CancelTimer(id); + ...... + ``` + +2. Configure compilation information. Specifically, add the subsystem SDK dependency to **BUILD.gn**. + + ``` + external_deps = [ "hiviewdfx:libxcollie" ] + ``` diff --git a/en/device-dev/subsystems/subsys-dfx-hidumper.md b/en/device-dev/subsystems/subsys-dfx-hidumper.md index 1060ab1dea8b06c80da014baf179278a140c8ff1..5c6bc09ecf931c46bb458e6d1c19111431bf0ddb 100644 --- a/en/device-dev/subsystems/subsys-dfx-hidumper.md +++ b/en/device-dev/subsystems/subsys-dfx-hidumper.md @@ -1,21 +1,18 @@ -# HiDumper Development +# HiDumper ## Overview - -### Introduction - HiDumper is a tool provided by OpenHarmony for developers, testers, and IDE tool engineers to obtain system information necessary for analyzing and locating faults. This section applies only to the standard system. -### Source Code Directories +## Source Code Directories ``` /base/hiviewdfx/hidumper ├── frameworks # Framework code │ ├── native # Core function code -│ │ │── include # Header files +│ │ │── include # Header files │ │ │── src # Source files │ │ │── common # Common function code │ │ │── executor # Process executor code @@ -34,14 +31,14 @@ HiDumper is a tool provided by OpenHarmony for developers, testers, and IDE tool ``` -## Usage +# Usage -### Command-Line Options +## Command-Line Options **Table 1** HiDumper command-line options -| Option| Description| +| Option| **Description**| | -------- | -------- | | -h | Shows the help Information.| | -t [timeout] | Specifies the timeout period, in seconds. The default value is **30**. Value **0** indicates no timeout limit.| @@ -56,14 +53,14 @@ HiDumper is a tool provided by OpenHarmony for developers, testers, and IDE tool | --net | Exports network information.| | --storage | Exports storage information.| | -p | Exports the process list and all process information.| -| -p [pid] | Exports all information about a specified process.| -| --cpuusage [pid] | Exports the CPU usage information based on **pid**.| +| -p [pid] | Exports all information about the specified process.| +| --cpuusage [pid] | Exports the CPU usage information. If **pid** is specified, the CPU usage of the corresponding process is exported.| | --cpufreq | Exports the actual CPU frequency.| -| --mem [pid] | Exports the memory usage information based on **pid**.| +| --mem [pid] | Export memory usage information. If **pid** is specified, the memory usage of the corresponding process is exported.| | --zip | Compresses the exported information to a specified folder.| -### Development Example +## Development Example HiDumper helps you export basic system information to locate and analyze faults. Complex parameters passed to sub-services and abilities must be enclosed in double quotation marks. @@ -118,7 +115,7 @@ The procedure is as follows: hidumper -s 3008 ``` -9. Run the **hidumper -e** command to obtain the crash information generated by the FaultLogger module. +9. Run the **hidumper -e** command to obtain the crash information generated by the FaultLoger module. ``` hidumper -e @@ -148,7 +145,7 @@ The procedure is as follows: hidumper -p 1024 ``` -14. Run the **hidumper --cpuusage [pid]** command to obtain the CPU usage information of the process whose PID has been specified. +14. Run the **hidumper --cpuusage [pid]** command to obtain the CPU usage information. If the PID of a process is specified, only the CPU usage of the process is returned. ``` hidumper --cpuusage @@ -161,7 +158,7 @@ The procedure is as follows: hidumper --cpufreq ``` -16. Run the **hidumper --mem [pid]** command to obtain all memory usage information of the process whose PID has been specified. +16. Run the **hidumper --mem [pid]** command to obtain all memory usage information. If the PID of a process is specified, only the memory usage of the process is returned. ``` hidumper --mem [pid] diff --git a/en/device-dev/subsystems/subsys-dfx-hitracechain.md b/en/device-dev/subsystems/subsys-dfx-hitracechain.md index e58467e1ca4814649adfc40bad1f28be1b96f4d5..f8a7c70451cf0b7b357492d7fd01ba9aca287e36 100644 --- a/en/device-dev/subsystems/subsys-dfx-hitracechain.md +++ b/en/device-dev/subsystems/subsys-dfx-hitracechain.md @@ -146,9 +146,7 @@ Some built-in communication mechanisms (such as ZIDL) of OpenHarmony already sup The following figure shows the process of transferring **traceid** in synchronous call. The process of transferring **traceid** in asynchronous call is similar. Extended communication mechanisms can also follow this implementation. - **Figure 5** Call chain trace in synchronous communication - ![](figures/call-chain-trace-in-synchronous-communication.png "call-chain-trace-in-synchronous-communication") The process is as follows: diff --git a/en/device-dev/subsystems/subsys-dfx-hitracemeter.md b/en/device-dev/subsystems/subsys-dfx-hitracemeter.md index bb609b7369d03ae82b7782421c3ec96344bcc840..12daba15d92b97ce4cc0a79a85ce461950dfaa8f 100644 --- a/en/device-dev/subsystems/subsys-dfx-hitracemeter.md +++ b/en/device-dev/subsystems/subsys-dfx-hitracemeter.md @@ -1,4 +1,4 @@ -# HiTraceMeter +# HiTraceMeter Development ## Introduction