diff --git a/en/application-dev/dfx/hiappevent-guidelines.md b/en/application-dev/dfx/hiappevent-guidelines.md index 48f725e080441281cd2e88820eeacc6032a2dbab..d19283fc375a870af2897a26fd91ce78aa7d3cf9 100644 --- a/en/application-dev/dfx/hiappevent-guidelines.md +++ b/en/application-dev/dfx/hiappevent-guidelines.md @@ -12,12 +12,10 @@ The following table provides only a brief description of related APIs. For detai **Table 1** APIs for application event logging -| API | Description | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| write(string eventName, EventType type, object keyValues, AsyncCallback\ callback): void | Logs application events in asynchronous mode. This API uses an asynchronous callback to return the result. | -| write(string eventName, EventType type, object keyValues): Promise\ | Logs application events in asynchronous mode. This API uses a promise to return the result. | -| write(AppEventInfo info, AsyncCallback\ callback): void | Logs application events by domain in asynchronous mode. This API uses an asynchronous callback to return the result.| -| write(AppEventInfo info): Promise\ | Logs application events by domain in asynchronous mode. This API uses a promise to return the result.| +| API | Description | +| ------------------------------------------------------------ | ---------------------------------------------------- | +| write(AppEventInfo info, AsyncCallback\ callback): void | Logs application events in asynchronous mode. This API uses an asynchronous callback to return the result.| +| write(AppEventInfo info): Promise\ | Logs application events in asynchronous mode. This API uses a promise to return the result. | When an asynchronous callback is used, the return value can be processed directly in the callback. @@ -49,12 +47,12 @@ For details about the result codes, see [Event Verification Result Codes](#event | Result Code| Cause | Verification Rules | Handling Method | | ------ | ----------------------------- | ------------------------------------------------------------ | ---------------------------------------------------------- | | 0 | N/A | Event verification is successful. | Event logging is normal. No action is required. | -| -1 | Invalid event name | The name is not empty and contains a maximum of 48 characters.
The name consists of only the following characters: digits (0 to 9), letters (a to z), and underscore \(_).
The name does not start with a digit or underscore \(_).| Ignore this event and do not perform logging. | +| -1 | Invalid event name | The name is not empty and contains a maximum of 48 characters.
The name consists of only the following characters: digits (0 to 9), letters (a to z), and underscore (\_).
The name does not start with a digit or underscore (\_).| Ignore this event and do not perform logging. | | -2 | Invalid event parameter type | The event name must be a string.
The event type must be a number.
The event parameter must be an object.| Ignore this event and do not perform logging. | -| -4 | Invalid event domain name | The name is not empty and contains a maximum of 32 characters.
The name consists of only the following characters: digits (0 to 9), letters (a to z), and underscore \(_).
The name does not start with a digit or underscore \(_).| Ignore this event and do not perform logging. | +| -4 | Invalid event domain name | The name is not empty and contains a maximum of 32 characters.
The name consists of only the following characters: digits (0 to 9), letters (a to z), and underscore (\_).
The name does not start with a digit or underscore (\_).| Ignore this event and do not perform logging. | | -99 | Application event logging disabled | Application event logging is disabled. | Ignore this event and do not perform logging. | | -100 | Unknown error | None. | Ignore this event and do not perform logging. | -| 1 | Invalid key name | The name is not empty and contains a maximum of 16 characters.
The name consists of only the following characters: digits (0 to 9), letters (a to z), and underscore \(_).
The name does not start with a digit or underscore \(_).
The name does not end with an underscore \(_).| Ignore the key-value pair and continue to perform logging. | +| 1 | Invalid key name | The name is not empty and contains a maximum of 16 characters.
The name consists of only the following characters: digits (0 to 9), letters (a to z), and underscore (\_).
The name does not start with a digit or underscore (\_).
The name does not end with an underscore (\_).| Ignore the key-value pair and continue to perform logging. | | 2 | Invalid key type | The key must be a string. | Ignore the key-value pair and continue to perform logging. | | 3 | Invalid value type | The supported value types vary depending on the programming language:
boolean, number, string, or Array [basic element]| Ignore the key-value pair and continue to perform logging. | | 4 | Invalid length for values of the string type| For a value of the string type, the maximum length is 8*1024 characters. | Truncate the value with the first 8*1024 characters retained, and continue to perform logging.| @@ -84,6 +82,7 @@ The following uses a one-time event watcher as an example to illustrate the deve .fontWeight(FontWeight.Bold) Button("1 writeTest").onClick(()=>{ + // Perform event logging based on the input event parameters. hiAppEvent.write({ domain: "test_domain", name: "test_event", @@ -100,6 +99,7 @@ The following uses a one-time event watcher as an example to illustrate the deve }) Button("2 addWatcherTest").onClick(()=>{ + // Add an event watcher based on the input subscription parameters. hiAppEvent.addWatcher({ name: "watcher1", appEventFilters: [{ domain: "test_domain" }], @@ -109,17 +109,23 @@ The following uses a one-time event watcher as an example to illustrate the deve timeOut: 2 }, onTrigger: function (curRow, curSize, holder) { + // If the holder object is null, return an error after recording it in the log. if (holder == null) { console.error("HiAppEvent holder is null"); return; } + // Set the size threshold to 1,000 bytes for obtaining an event package. + holder.setSize(1000); let eventPkg = null; + // Obtain the event package based on the configured size threshold. If returned event package is null, all event data has been obtained. while ((eventPkg = holder.takeNext()) != null) { - console.info("HiAppEvent eventPkg.packageId=" + eventPkg.packageId); - console.info("HiAppEvent eventPkg.row=" + eventPkg.row); - console.info("HiAppEvent eventPkg.size=" + eventPkg.size); + // Parse the obtained event package and display the result on the Log page. + console.info('HiAppEvent eventPkg.packageId=' + eventPkg.packageId); + console.info('HiAppEvent eventPkg.row=' + eventPkg.row); + console.info('HiAppEvent eventPkg.size=' + eventPkg.size); + // Traverse and parse event string arrays in the obtained event package. for (const eventInfo of eventPkg.data) { - console.info("HiAppEvent eventPkg.data=" + eventInfo); + console.info('HiAppEvent eventPkg.data=' + eventInfo); } } } @@ -127,6 +133,7 @@ The following uses a one-time event watcher as an example to illustrate the deve }) Button("3 removeWatcherTest").onClick(()=>{ + // Remove the specified event watcher. hiAppEvent.removeWatcher({ name: "watcher1" }) @@ -157,9 +164,3 @@ The following uses a one-time event watcher as an example to illustrate the deve ``` 5. On the application UI, touch button 3 to remove the event watcher. Then, touch button 1 for multiple times to perform application event logging. In such a case, there will be no log information about the callback invoked by the event watcher. - -## Samples - -The following sample is provided to help you better understand how to develop the application event logging feature: - -- [`JsDotTest` (JS) (API8)](https://gitee.com/openharmony/applications_app_samples/tree/master/DFX/JsDotTest) diff --git a/en/application-dev/reference/apis/js-apis-call.md b/en/application-dev/reference/apis/js-apis-call.md index ac82d0b2e610751bd000849ec35337363b0dcb3a..0d7078f285a207dd866e6d9fe4ed1a6dda2f9fbc 100644 --- a/en/application-dev/reference/apis/js-apis-call.md +++ b/en/application-dev/reference/apis/js-apis-call.md @@ -834,7 +834,7 @@ promise.then(data => { ## call.reject7+ -reject\(callId: number, options: RejectMessageOption, callback: AsyncCallback\): void +reject\(callId: number, options: RejectMessageOptions, callback: AsyncCallback\): void Rejects a call based on the specified call ID and options. This API uses an asynchronous callback to return the result. diff --git a/en/application-dev/reference/apis/js-apis-contact.md b/en/application-dev/reference/apis/js-apis-contact.md index ee5cf3137c7aa5d1ef6cb8ef1c1ef47ef8b35236..aa0f989cd22f2977408d7de51b84370001c1a730 100644 --- a/en/application-dev/reference/apis/js-apis-contact.md +++ b/en/application-dev/reference/apis/js-apis-contact.md @@ -194,8 +194,8 @@ Updates a contact based on the specified contact information and attributes. Thi contact.updateContact({ fullName: {fullName: 'xxx'}, phoneNumbers: [{phoneNumber: '138xxxxxxxx'}] - },{ - attributes:[contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME] + }, { + attributes: [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME] }, (err) => { if (err) { console.log('updateContact callback: err->${JSON.stringify(err)}'); @@ -449,7 +449,7 @@ Queries my card based on the specified contact attributes. This API uses a promi ```js let promise = contact.queryMyCard({ - attributes:['ATTR_EMAIL', 'ATTR_NAME'] + attributes: [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME] }); promise.then((data) => { console.log(`queryMyCard success: data->${JSON.stringify(data)}`); @@ -467,7 +467,7 @@ Selects a contact. This API uses an asynchronous callback to return the result. **Permission required**: ohos.permission.READ_CONTACTS -**System capability**: SystemCapability.Applications.Contacts and SystemCapability.Applications.ContactsData +**System capability**: SystemCapability.Applications.Contacts and SystemCapability.Applications.Contacts **Parameters** | Name | Type | Mandatory| Description | @@ -495,7 +495,7 @@ Selects a contact. This API uses a promise to return the result. **Permission required**: ohos.permission.READ_CONTACTS -**System capability**: SystemCapability.Applications.Contacts and SystemCapability.Applications.ContactsData +**System capability**: SystemCapability.Applications.Contacts **Return Value** | Type | Description | diff --git a/en/application-dev/reference/apis/js-apis-hisysevent.md b/en/application-dev/reference/apis/js-apis-hisysevent.md index e3c08ce24cf92eda9534812d664aa466c4b7c1ef..9168068677b76710c3945e521803529373badf41 100644 --- a/en/application-dev/reference/apis/js-apis-hisysevent.md +++ b/en/application-dev/reference/apis/js-apis-hisysevent.md @@ -207,7 +207,7 @@ let ret = hiSysEvent.addWatcher(watcher) ## hiSysEvent.removeWatcher -removeWatcher(wathcer: Watcher): number +removeWatcher(watcher: Watcher): number Removes a watcher used for event subscription. diff --git a/en/application-dev/reference/apis/js-apis-net-connection.md b/en/application-dev/reference/apis/js-apis-net-connection.md index ec63d11121dcd5138d11d7a2e1898833deaaf9c7..d362ed5578ebe3a8829fdc6a9924afe8f81f9525 100644 --- a/en/application-dev/reference/apis/js-apis-net-connection.md +++ b/en/application-dev/reference/apis/js-apis-net-connection.md @@ -67,6 +67,8 @@ hasDefaultNet(callback: AsyncCallback\): void Checks whether the default data network is activated. This API uses an asynchronous callback to return the result. +**Required permission**: ohos.permission.GET_NETWORK_INFO + **System capability**: SystemCapability.Communication.NetManager.Core **Parameters** @@ -90,6 +92,8 @@ hasDefaultNet(): Promise\ Checks whether the default data network is activated. This API uses a promise to return the result. +**Required permission**: ohos.permission.GET_NETWORK_INFO + **System capability**: SystemCapability.Communication.NetManager.Core **Return Value** diff --git a/en/application-dev/reference/apis/js-apis-radio.md b/en/application-dev/reference/apis/js-apis-radio.md index d094a5c7e3abd27ebc042ab377543a3d2898b1e1..a2eab97e2dfeda8d808da429b8ce650b2f365b1e 100644 --- a/en/application-dev/reference/apis/js-apis-radio.md +++ b/en/application-dev/reference/apis/js-apis-radio.md @@ -384,6 +384,27 @@ promise.then(data => { }); ``` +## radio.isNrSupported7+ + +isNrSupported\(\): boolean + +Checks whether the current device supports 5G \(NR\). + +**System capability**: SystemCapability.Telephony.CoreService + +**Return value** + +| Type | Description | +| ------- | -------------------------------- | +| boolean | - **true**: The current device supports 5G \(NR\).
- **false**: The current device does not support 5G \(NR\).| + +**Example** + +```js +let result = radio.isNrSupported(); +console.log("Result: "+ result); +`` + ## radio.isNrSupported8+ diff --git a/en/application-dev/reference/apis/js-apis-sim.md b/en/application-dev/reference/apis/js-apis-sim.md index a2d761225c3169bd6d9f5a7603232d4050c0342b..2c2c074b52e36b31e7b5f7b3f053370143d6d6eb 100644 --- a/en/application-dev/reference/apis/js-apis-sim.md +++ b/en/application-dev/reference/apis/js-apis-sim.md @@ -2657,8 +2657,6 @@ getOpKey(slotId: number, callback: AsyncCallback): void Obtains the opkey of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. -**System API**: This is a system API. - **System capability**: SystemCapability.Telephony.CoreService **Parameters** @@ -2683,8 +2681,6 @@ getOpKey(slotId: number): Promise Obtains the opkey of the SIM card in the specified slot. This API uses a promise to return the result. -**System API**: This is a system API. - **System capability**: SystemCapability.Telephony.CoreService **Parameters** @@ -2716,8 +2712,6 @@ getOpName(slotId: number, callback: AsyncCallback): void Obtains the OpName of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. -**System API**: This is a system API. - **System capability**: SystemCapability.Telephony.CoreService **Parameters** @@ -2742,8 +2736,6 @@ getOpName(slotId: number): Promise Obtains the OpName of the SIM card in the specified slot. This API uses a promise to return the result. -**System API**: This is a system API. - **System capability**: SystemCapability.Telephony.CoreService **Parameters** 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 7d8018a4e82916df0c218a10ca7d5e8fdb9e6364..d06d7d34aa76a98cdc3ffc67419f615414d55787 100644 --- a/en/application-dev/reference/apis/js-apis-telephony-data.md +++ b/en/application-dev/reference/apis/js-apis-telephony-data.md @@ -79,7 +79,7 @@ This is a system API. | Name | Type | Mandatory| Description | | -------- | --------------------- | ---- | ------------------------------------------------------------ | -| slotId | number | Yes | SIM card slot ID.
- **0**: card slot 1
- **1**: card slot 2
- **-1**: clearing the default configuration| +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2
- **-1**: clearing the default configuration| | callback | AsyncCallback\ | Yes | Callback used to return the result. | **Example** @@ -90,6 +90,29 @@ data.setDefaultCellularDataSlotId(0,(err, data) => { }); ``` +## data.getDefaultCellularDataSlotIdSync + +getDefaultCellularDataSlotIdSync(): number + +Obtains the default SIM card used for mobile data. + +**Required permission**: ohos.permission.GET_NETWORK_INFO + +**System capability**: SystemCapability.Telephony.CellularData + +**Return value** + +| Type | Description | +| ------ | -------------------------------------------------- | +| number | Card slot ID.
**0**: card slot 1
**1**: card slot 2 | + +**Example** + +```js +console.log("Result: "+ data.getDefaultCellularDataSlotIdSync()) +``` + + ## data.setDefaultCellularDataSlotId setDefaultCellularDataSlotId(slotId: number): Promise\ @@ -104,13 +127,13 @@ This is a system API. **Parameters** -| Name| Type | Mandatory| Description | +| Name| Type | Mandatory| Description | | ------ | ------ | ---- | ------------------------------------------------------------ | -| slotId | number | Yes | SIM card slot ID.
- **0**: card slot 1
- **1**: card slot 2
- **-1**: clearing the default configuration| +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2
- **-1**: clearing the default configuration| **Return value** -| Type | Description | +| Type | Description | | -------------- | ------------------------------- | | Promise<\void\> | Promise used to return the result. | @@ -135,7 +158,7 @@ Obtains the cellular data flow type, which can be uplink or downlink. This API u **Parameters** -| Name | Type | Mandatory| Description | +| Name | Type | Mandatory| Description | | -------- | ---------------------------------------------- | ---- | ---------- | | callback | AsyncCallback\<[DataFlowType](#dataflowtype)\> | Yes | Callback used to return the result.| @@ -204,7 +227,7 @@ Obtains the connection status of the PS domain. This API uses a promise to retur **Return value** -| Type | Description | +| Type | Description | | ------------------------------------------------ | ------------------------------------- | | Promise\<[DataConnectState](#dataconnectstate)\> | Promise used to return the result.| diff --git a/en/application-dev/reference/apis/js-apis-update.md b/en/application-dev/reference/apis/js-apis-update.md index ab8fc8e866ae68175f6ddabc0be83ac1f2803b5f..04aaf9e335f4e01762e64a3c11d1d036c5f2225a 100644 --- a/en/application-dev/reference/apis/js-apis-update.md +++ b/en/application-dev/reference/apis/js-apis-update.md @@ -7,7 +7,7 @@ There are two types of updates: SD card update and over the air (OTA) update. - The SD card update depends on the update packages and SD cards. - The OTA update depends on the server deployed by the device manufacturer for managing update packages. The OTA server IP address is passed by the caller. The request interface is fixed and developed by the device manufacturer. -> **Note:** +> **NOTE** > > The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > @@ -43,13 +43,13 @@ Obtains an **OnlineUpdater** object. ```ts try { - var upgradeInfo = { + const upgradeInfo = { upgradeApp: "com.ohos.ota.updateclient", businessType: { vendor: update.BusinessVendor.PUBLIC, subType: update.BusinessSubType.FIRMWARE } - } + }; let updater = update.getOnlineUpdater(upgradeInfo); } catch(error) { console.error(`Fail to get updater error: ${error}`); @@ -226,22 +226,22 @@ Obtains the description file of the new version. This API uses an asynchronous c | Name | Type | Mandatory | Description | | ------------------ | ---------------------------------------- | ---- | -------------- | | versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information. | -| descriptionOptions | [DescriptionOptions](#descriptionoptions) | Yes | Options of the description file. | +| descriptionOptions | [DescriptionOptions](#descriptionoptions) | Yes | Options of the description file. | | callback | AsyncCallback\>) | Yes | Callback used to return the result.| **Example** ```ts // Version digest information -var versionDigestInfo = { +const versionDigestInfo = { versionDigest: "versionDigest" // Version digest information in the check result -} +}; // Options of the description file -var descriptionOptions = { - format: DescriptionFormat.STANDARD, // Standard format +const descriptionOptions = { + format: update.DescriptionFormat.STANDARD, // Standard format language: "zh-cn" // Chinese -} +}; updater.getNewVersionDescription(versionDigestInfo, descriptionOptions, (err, info) => { console.log(`getNewVersionDescription info ${JSON.stringify(info)}`); @@ -276,15 +276,15 @@ Obtains the description file of the new version. This API uses a promise to retu ```ts // Version digest information -var versionDigestInfo = { +const versionDigestInfo = { versionDigest: "versionDigest" // Version digest information in the check result -} +}; // Options of the description file -var descriptionOptions = { - format: DescriptionFormat.STANDARD, // Standard format +const descriptionOptions = { + format: update.DescriptionFormat.STANDARD, // Standard format language: "zh-cn" // Chinese -} +}; updater.getNewVersionDescription(versionDigestInfo, descriptionOptions).then(info => { console.log(`getNewVersionDescription promise info ${JSON.stringify(info)}`); @@ -368,10 +368,10 @@ Obtains the description file of the current version. This API uses an asynchrono ```ts // Options of the description file -var descriptionOptions = { - format: DescriptionFormat.STANDARD, // Standard format +const descriptionOptions = { + format: update.DescriptionFormat.STANDARD, // Standard format language: "zh-cn" // Chinese -} +}; updater.getCurrentVersionDescription(descriptionOptions, (err, info) => { console.log(`getCurrentVersionDescription info ${JSON.stringify(info)}`); @@ -405,10 +405,10 @@ Obtains the description file of the current version. This API uses a promise to ```ts // Options of the description file -var descriptionOptions = { - format: DescriptionFormat.STANDARD, // Standard format +const descriptionOptions = { + format: update.DescriptionFormat.STANDARD, // Standard format language: "zh-cn" // Chinese -} +}; updater.getCurrentVersionDescription(descriptionOptions).then(info => { console.log(`getCurrentVersionDescription promise info ${JSON.stringify(info)}`); @@ -483,21 +483,21 @@ Downloads the new version. This API uses an asynchronous callback to return the | ----------------- | --------------------------------------- | ---- | ---------------------------------- | | versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information. | | downloadOptions | [DownloadOptions](#downloadoptions) | Yes | Download options. | -| callback | AsyncCallback\ | Yes | Callback invoked to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.| +| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.| **Example** ```ts // Version digest information -var versionDigestInfo = { +const versionDigestInfo = { versionDigest: "versionDigest" // Version digest information in the check result -} +}; // Download options -var downloadOptions = { +const downloadOptions = { allowNetwork: update.NetType.CELLULAR, // Whether to allow download over data network order: update.Order.DOWNLOAD // Download -} +}; updater.download(versionDigestInfo, downloadOptions, (err) => { console.log(`download error ${JSON.stringify(err)}`); }); @@ -524,21 +524,21 @@ Downloads the new version. This API uses a promise to return the result. | Type | Description | | -------------- | -------------------------- | -| Promise\ | Promise that returns no value.| +| Promise\ | Promise Promise that returns no value.| **Example** ```ts // Version digest information -var versionDigestInfo = { +const versionDigestInfo = { versionDigest: "versionDigest" // Version digest information in the check result -} +}; // Download options -var downloadOptions = { +const downloadOptions = { allowNetwork: update.NetType.CELLULAR, // Whether to allow download over data network order: update.Order.DOWNLOAD // Download -} +}; updater.download(versionDigestInfo, downloadOptions).then(() => { console.log(`download start`); }).catch(err => { @@ -562,20 +562,20 @@ Resumes download of the new version. This API uses an asynchronous callback to r | --------------------- | ---------------------------------------- | ---- | ------------------------------------ | | versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information. | | resumeDownloadOptions | [ResumeDownloadOptions](#resumedownloadoptions) | Yes | Options for resuming download. | -| callback | AsyncCallback\ | Yes | Callback invoked to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.| +| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.| **Example** ```ts // Version digest information -var versionDigestInfo = { +const versionDigestInfo = { versionDigest: "versionDigest" // Version digest information in the check result -} +}; // Options for resuming download -var resumeDownloadOptions = { +const resumeDownloadOptions = { allowNetwork: update.NetType.CELLULAR, // Whether to allow download over data network -} +}; updater.resumeDownload(versionDigestInfo, resumeDownloadOptions, (err) => { console.log(`resumeDownload error ${JSON.stringify(err)}`); }); @@ -608,14 +608,14 @@ Resumes download of the new version. This API uses a promise to return the resul ```ts // Version digest information -var versionDigestInfo = { +const versionDigestInfo = { versionDigest: "versionDigest" // Version digest information in the check result -} +}; // Options for resuming download -var resumeDownloadOptions = { +const resumeDownloadOptions = { allowNetwork: update.NetType.CELLULAR, // Whether to allow download over data network -} +}; updater.resumeDownload(versionDigestInfo, resumeDownloadOptions).then(value => { console.log(`resumeDownload start`); }).catch(err => { @@ -639,20 +639,20 @@ Pauses download of the new version. This API uses an asynchronous callback to re | -------------------- | ---------------------------------------- | ---- | ------------------------------------ | | versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information. | | pauseDownloadOptions | [PauseDownloadOptions](#pausedownloadoptions) | Yes | Options for pausing download. | -| callback | AsyncCallback\ | Yes | Callback invoked to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.| +| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.| **Example** ```ts // Version digest information -var versionDigestInfo = { +const versionDigestInfo = { versionDigest: "versionDigest" // Version digest information in the check result -} +}; // Options for pausing download -var pauseDownloadOptions = { +const pauseDownloadOptions = { isAllowAutoResume: true // Whether to allow automatic resuming of download -} +}; updater.pauseDownload(versionDigestInfo, pauseDownloadOptions, (err) => { console.log(`pauseDownload error ${JSON.stringify(err)}`); }); @@ -685,14 +685,14 @@ Resumes download of the new version. This API uses a promise to return the resul ```ts // Version digest information -var versionDigestInfo = { +const versionDigestInfo = { versionDigest: "versionDigest" // Version digest information in the check result -} +}; // Options for pausing download -var pauseDownloadOptions = { +const pauseDownloadOptions = { isAllowAutoResume: true // Whether to allow automatic resuming of download -} +}; updater.pauseDownload(versionDigestInfo, pauseDownloadOptions).then(value => { console.log(`pauseDownload`); }).catch(err => { @@ -716,20 +716,20 @@ Updates the version. This API uses an asynchronous callback to return the result | ----------------- | --------------------------------------- | ---- | ------------------------------------ | | versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information. | | upgradeOptions | [UpgradeOptions](#upgradeoptions) | Yes | Update options. | -| callback | AsyncCallback\ | Yes | Callback invoked to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.| +| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.| **Example** ```ts // Version digest information -var versionDigestInfo = { +const versionDigestInfo = { versionDigest: "versionDigest" // Version digest information in the check result -} +}; // Installation options -var upgradeOptions = { +const upgradeOptions = { order: update.Order.INSTALL // Installation command -} +}; updater.upgrade(versionDigestInfo, upgradeOptions, (err) => { console.log(`upgrade error ${JSON.stringify(err)}`); }); @@ -762,14 +762,14 @@ Updates the version. This API uses a promise to return the result. ```ts // Version digest information -var versionDigestInfo = { +const versionDigestInfo = { versionDigest: "versionDigest" // Version digest information in the check result -} +}; // Installation options -var upgradeOptions = { +const upgradeOptions = { order: update.Order.INSTALL // Installation command -} +}; updater.upgrade(versionDigestInfo, upgradeOptions).then(() => { console.log(`upgrade start`); }).catch(err => { @@ -793,20 +793,20 @@ Clears errors. This API uses an asynchronous callback to return the result. | ----------------- | --------------------------------------- | ---- | ------------------------------------ | | versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information. | | clearOptions | [ClearOptions](#clearoptions) | Yes | Clear options. | -| callback | AsyncCallback\ | Yes | Callback invoked to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.| +| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.| **Example** ```ts // Version digest information -var versionDigestInfo = { +const versionDigestInfo = { versionDigest: "versionDigest" // Version digest information in the check result -} +}; // Options for clearing errors -var clearOptions = { +const clearOptions = { status: update.UpgradeStatus.UPGRADE_FAIL, -} +}; updater.clearError(versionDigestInfo, clearOptions, (err) => { console.log(`clearError error ${JSON.stringify(err)}`); }); @@ -839,14 +839,14 @@ Clears errors. This API uses a promise to return the result. ```ts // Version digest information -var versionDigestInfo = { +const versionDigestInfo = { versionDigest: "versionDigest" // Version digest information in the check result -} +}; // Options for clearing errors -var clearOptions = { +lconstet clearOptions = { status: update.UpgradeStatus.UPGRADE_FAIL, -} +}; updater.clearError(versionDigestInfo, clearOptions).then(() => { console.log(`clearError success`); }).catch(err => { @@ -926,11 +926,11 @@ Sets the update policy. This API uses an asynchronous callback to return the res **Example** ```ts -let policy = { +const policy = { downloadStrategy: false, autoUpgradeStrategy: false, autoUpgradePeriods: [ { start: 120, end: 240 } ] // Automatic update period, in minutes -} +}; updater.setUpgradePolicy(policy, (err) => { console.log(`setUpgradePolicy result: ${err}`); }); @@ -961,11 +961,11 @@ Sets the update policy. This API uses a promise to return the result. **Example** ```ts -let policy = { +const policy = { downloadStrategy: false, autoUpgradeStrategy: false, autoUpgradePeriods: [ { start: 120, end: 240 } ] // Automatic update period, in minutes -} +}; updater.setUpgradePolicy(policy).then(() => { console.log(`setUpgradePolicy success`); }).catch(err => { @@ -987,7 +987,7 @@ Terminates the update. This API uses an asynchronous callback to return the resu | Name | Type | Mandatory | Description | | -------- | -------------------- | ---- | -------------------------------------- | -| callback | AsyncCallback\ | Yes | Callback invoked to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.| +| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.| **Example** @@ -1041,10 +1041,10 @@ Enables listening for update events. This API uses an asynchronous callback to r **Example** ```ts -var eventClassifyInfo = { +const eventClassifyInfo = { eventClassify: update.EventClassify.TASK, // Listening for update events extraInfo: "" -} +}; updater.on(eventClassifyInfo, (eventInfo) => { console.log("updater on " + JSON.stringify(eventInfo)); @@ -1068,10 +1068,10 @@ Disables listening for update events. This API uses an asynchronous callback to **Example** ```ts -var eventClassifyInfo = { +const eventClassifyInfo = { eventClassify: update.EventClassify.TASK, // Listening for update events extraInfo: "" -} +}; updater.off(eventClassifyInfo, (eventInfo) => { console.log("updater off " + JSON.stringify(eventInfo)); @@ -1084,7 +1084,7 @@ updater.off(eventClassifyInfo, (eventInfo) => { factoryReset(callback: AsyncCallback\): void -Restore the device to its factory settings. This API uses an asynchronous callback to return the result. +Restores the device to its factory settings. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Update.UpdateService @@ -1094,7 +1094,7 @@ Restore the device to its factory settings. This API uses an asynchronous callba | Name | Type | Mandatory | Description | | -------- | -------------------- | ---- | -------------------------------------- | -| callback | AsyncCallback\ | Yes | Callback invoked to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.| +| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.| **Example** @@ -1108,7 +1108,7 @@ restorer.factoryReset((err) => { factoryReset(): Promise\ -Restore the device to its factory settings. This API uses a promise to return the result. +Restores the device to its factory settings. This API uses a promise to return the result. **System capability**: SystemCapability.Update.UpdateService @@ -1118,7 +1118,7 @@ Restore the device to its factory settings. This API uses a promise to return th | Type | Description | | -------------- | -------------------------- | -| Promise\ | Promise that returns no value.| +| Promise\ | Promise Promise that returns no value.| **Example** @@ -1153,10 +1153,10 @@ Verifies the update package. This API uses an asynchronous callback to return th **Example** ```ts -var upgradeFile = { +const upgradeFile = { fileType: update.ComponentType.OTA, // OTA package filePath: "path" // Path of the local update package -} +}; localUpdater.verifyUpgradePackage(upgradeFile, "cerstFilePath", (err) => { console.log(`factoryReset error ${JSON.stringify(err)}`); @@ -1189,10 +1189,10 @@ Verifies the update package. This API uses a promise to return the result. **Example** ```ts -var upgradeFile = { +const upgradeFile = { fileType: update.ComponentType.OTA, // OTA package filePath: "path" // Path of the local update package -} +}; localUpdater.verifyUpgradePackage(upgradeFile, "cerstFilePath").then(() => { console.log(`verifyUpgradePackage success`); }).catch(err => { @@ -1214,15 +1214,15 @@ Installs the update package. This API uses an asynchronous callback to return th | Name | Type | Mandatory | Description | | ----------- | ---------------------------------- | ---- | --------------------------------------- | | upgradeFile | Array<[UpgradeFile](#upgradefile)> | Yes | Update file. | -| callback | AsyncCallback\ | Yes | Callback invoked to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.| +| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.| **Example** ```ts -var upgradeFiles = [{ +const upgradeFiles = [{ fileType: update.ComponentType.OTA, // OTA package filePath: "path" // Path of the local update package -}] +}]; localUpdater.applyNewVersion(upgradeFiles, (err) => { console.log(`applyNewVersion error ${JSON.stringify(err)}`); @@ -1248,10 +1248,10 @@ Installs the update package. This API uses a promise to return the result. **Example** ```ts -var upgradeFiles = [{ +localUpdater upgradeFiles = [{ fileType: update.ComponentType.OTA, // OTA package filePath: "path" // Path of the local update package -}] +}]; localUpdater.applyNewVersion(upgradeFiles).then(() => { console.log(`applyNewVersion success`); }).catch(err => { @@ -1276,10 +1276,10 @@ Enables listening for update events. This API uses an asynchronous callback to r **Example** ```ts -var eventClassifyInfo = { +const eventClassifyInfo = { eventClassify: update.EventClassify.TASK, // Listening for update events extraInfo: "" -} +}; function onTaskUpdate(eventInfo) { console.log(`on eventInfo id `, eventInfo.eventId); @@ -1305,10 +1305,10 @@ Disables listening for update events. This API uses an asynchronous callback to **Example** ```ts -var eventClassifyInfo = { +const eventClassifyInfo = { eventClassify: update.EventClassify.TASK, // Listening for update events extraInfo: "" -} +}; function onTaskUpdate(eventInfo) { console.log(`on eventInfo id `, eventInfo.eventId); @@ -1337,7 +1337,7 @@ Enumerates update service types. | Name | Type | Mandatory | Description | | ------- | ----------------------------------- | ---- | ---- | | vendor | [BusinessVendor](#businessvendor) | Yes | Application vendor. | -| subType | [BusinessSubType](#businesssubtype) | Yes | Type | +| subType | [BusinessSubType](#businesssubtype) | Yes | Update service type. | ## CheckResult @@ -1377,11 +1377,11 @@ Represents a version component. **System capability**: SystemCapability.Update.UpdateService -| Parameter | Type | Mandatory | Description | +| Name | Type | Mandatory | Description | | --------------- | ----------------------------------- | ---- | -------- | | componentId | string | Yes | Component ID. | -| componentType | [ComponentType](#componenttype) | Yes | Component type. | -| upgradeAction | [UpgradeAction](#upgradeaction) | Yes | Update mode. | +| componentType | [ComponentType](#componenttype) | Yes | Color component type. | +| upgradeAction | [UpgradeAction](#upgradeaction) | Yes | Represents an update mode. | | displayVersion | string | Yes | Display version number. | | innerVersion | string | Yes | Internal version number. | | size | number | Yes | Update package size. | @@ -1498,7 +1498,7 @@ Represents an update policy. ## UpgradePeriod -Represents a period for automatic update. +Represents an automatic update period. **System capability**: SystemCapability.Update.UpdateService @@ -1516,7 +1516,7 @@ Represents task information. | Name | Type | Mandatory | Description | | --------- | --------------------- | ---- | ------ | | existTask | bool | Yes | Whether a task exists.| -| taskBody | [TaskBody](#taskinfo) | Yes | Task data. | +| taskBody | [TaskBody](#taskinfo) | Yes | Represents task data. | ## EventInfo @@ -1526,7 +1526,7 @@ Represents event type information. | Name | Type | Mandatory | Description | | -------- | --------------------- | ---- | ---- | -| eventId | [EventId](#eventid) | Yes | Event ID.| +| eventId | [EventId](#eventid) | Yes | Enumerates event IDs.| | taskBody | [TaskBody](#taskinfo) | Yes | Task data.| ## TaskBody @@ -1554,7 +1554,7 @@ Represents an error message. | Name | Type | Mandatory | Description | | ------------ | ------ | ---- | ---- | | errorCode | number | Yes | Error code. | -| errorMessage | string | Yes | Error description.| +| errorMessage | string | Yes | Error message.| ## EventClassifyInfo @@ -1580,7 +1580,7 @@ Represents an update file. ## UpgradeTaskCallback -### (eventInfo: [EventInfo](#eventinfo)): void +(eventInfo: EventInfo): void Represents an event callback.