From 4074086a6b20b796ed3b50491ae1abe53ee71e98 Mon Sep 17 00:00:00 2001 From: shawn_he Date: Tue, 30 May 2023 15:19:03 +0800 Subject: [PATCH] update doc Signed-off-by: shawn_he --- en/application-dev/connectivity/Readme-EN.md | 1 - .../connectivity/net-policy-management.md | 402 ----- .../reference/apis/Readme-EN.md | 1 + .../reference/apis/js-apis-call.md | 634 ++++++- .../reference/apis/js-apis-i18n.md | 69 +- .../reference/apis/js-apis-intl.md | 41 +- .../reference/apis/js-apis-loglibrary.md | 319 ++++ .../reference/apis/js-apis-logs.md | 245 ++- .../reference/apis/js-apis-net-policy.md | 1555 ----------------- .../reference/apis/js-apis-rpc.md | 10 +- .../reference/apis/js-apis-shortKey.md | 81 + .../reference/apis/js-apis-system-battery.md | 8 +- .../apis/js-apis-system-brightness.md | 42 +- .../reference/apis/js-apis-thermal.md | 6 +- .../reference/errorcodes/Readme-EN.md | 1 - .../reference/errorcodes/errorcode-i18n.md | 2 +- .../errorcodes/errorcode-loglibrary.md | 24 + .../errorcodes/errorcode-net-policy.md | 63 - .../subsys-power-mode-customization.md | 14 +- .../subsystems/subsys-thermal_control.md | 7 +- 20 files changed, 1335 insertions(+), 2190 deletions(-) delete mode 100644 en/application-dev/connectivity/net-policy-management.md create mode 100644 en/application-dev/reference/apis/js-apis-loglibrary.md delete mode 100644 en/application-dev/reference/apis/js-apis-net-policy.md create mode 100644 en/application-dev/reference/apis/js-apis-shortKey.md create mode 100644 en/application-dev/reference/errorcodes/errorcode-loglibrary.md delete mode 100644 en/application-dev/reference/errorcodes/errorcode-net-policy.md diff --git a/en/application-dev/connectivity/Readme-EN.md b/en/application-dev/connectivity/Readme-EN.md index 59df854e8a..c09ca21b6d 100755 --- a/en/application-dev/connectivity/Readme-EN.md +++ b/en/application-dev/connectivity/Readme-EN.md @@ -5,7 +5,6 @@ - [HTTP Data Request](http-request.md) - [WebSocket Connection](websocket-connection.md) - [Socket Connection](socket-connection.md) - - [Network Policy Management](net-policy-management.md) - [Network Sharing](net-sharing.md) - [Ethernet Connection](net-ethernet.md) - [Network Connection Management](net-connection-manager.md) diff --git a/en/application-dev/connectivity/net-policy-management.md b/en/application-dev/connectivity/net-policy-management.md deleted file mode 100644 index 6450bd671e..0000000000 --- a/en/application-dev/connectivity/net-policy-management.md +++ /dev/null @@ -1,402 +0,0 @@ -# Network Policy Management - -## Introduction - -The Network Policy Management module allows you to restrict network capabilities by setting network policies, including cellular network policy, sleep/power-saving mode policy, and background network policy, and to reset network policies as needed. - -> **NOTE** -> To maximize the application running efficiency, most API calls are called asynchronously in callback or promise mode. The following code examples use the callback mode. For details about the APIs, see [sms API Reference](../reference/apis/js-apis-net-policy.md). - -## Basic Concepts - -- Sleep mode: A mode in which the system shuts down some idle components and peripherals to enter the low-power mode and restricts some applications from accessing the network. -- Power-saving mode: A mode in which the system disables certain functions and features to save power. When this mode is enabled, the system performance deteriorates and some applications are restricted from accessing the network. -- Traffic-saving mode: A mode in which the system restricts background applications that use the metering network. It is equivalent to the background network policy. -- Cellular network: A mobile communication network. -- Metering network: A mobile network with preconfigured traffic quota, WLAN network, or Ethernet network. - -## **Constraints** - -- Programming language: C++ and JS -- System: Linux kernel -- 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. - -## When to Use - -Typical application scenarios of network policy management are as follows: - -- Managing the metering network policy: Set the metering network quota and obtain the configured metering network policy. -- Managing network access for an application in the background: Set and obtain the status of the background network restriction switch, and check whether the application indicated by the specified UID can access the network in the background. -- Managing the metering network access policy: Set and obtain the policy for the application indicated by the specified UID to access the metering network, and obtain the UIDs of the applications for which the policy is configured. -- Restoring network policies -- Checking whether an application indicated by the specified UID can access a metering or non-metering network -- Adding a UID to or removing a UID from the sleep mode allowlist, and obtaining the sleep mode allowlist -- Adding a UID to or removing a UID from the power-saving mode allowlist, and obtaining the power-saving mode allowlist -- Updating the network notification policy - -The following describes the development procedure specific to each application scenario. - -## Available APIs - -For the complete list of APIs and example code, see [Network Policy Management](../reference/apis/js-apis-net-policy.md). - -| Type| API| Description| -| ---- | ---- | ---- | -| ohos.net.policy | function setBackgroundPolicy(isAllowed: boolean, callback: AsyncCallback\): void |Sets a background network policy. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function isBackgroundAllowed(callback: AsyncCallback\): void; |Obtains the background network policy. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function setPolicyByUid(uid: number, policy: NetUidPolicy, callback: AsyncCallback\): void; |Sets an application-specific network policy by **uid**. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function getPolicyByUid(uid: number, callback: AsyncCallback\): void;| Obtains an application-specific network policy by **uid**. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function getUidsByPolicy(policy: NetUidPolicy, callback: AsyncCallback\>): void; | Obtains the UID array of applications configured with a certain application-specific network policy. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function getNetQuotaPolicies(callback: AsyncCallback\>): void; |Obtains the network quota policies. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function setNetQuotaPolicies(quotaPolicies: Array\, callback: AsyncCallback\): void; |Sets an array of network quota policies. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function restoreAllPolicies(iccid: string, callback: AsyncCallback\): void; | Restores all the policies (cellular network, background network, firewall, and application-specific network policies) for the given SIM card. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function isUidNetAllowed(uid: number, isMetered: boolean, callback: AsyncCallback\): void; | Checks whether an application is allowed to access metering or non-metering networks. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function isUidNetAllowed(uid: number, iface: string, callback: AsyncCallback\): void; | Checks whether an application is allowed to access the given network. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function setDeviceIdleAllowList(uid: number, isAllowed: boolean, callback: AsyncCallback\): void; | Sets whether to add an application to the device idle allowlist. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function getDeviceIdleAllowList(callback: AsyncCallback\>): void; | Obtains the UID array of applications that are on the device idle allowlist. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function getBackgroundPolicyByUid(uid: number, callback: AsyncCallback\): void; | Obtains the background network policies configured for the given application. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function resetPolicies(iccid: string, callback: AsyncCallback\): void; | Restores all the policies (cellular network, background network, firewall, and application-specific network policies) for the given SIM card. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function updateRemindPolicy(netType: NetBearType, iccid: string, remindType: RemindType, callback: AsyncCallback\): void; | Updates a reminder policy. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function setPowerSaveAllowList(uid: number, isAllowed: boolean, callback: AsyncCallback\): void; | Sets whether to add an application to the power-saving allowlist. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function getPowerSaveAllowList(callback: AsyncCallback\>): void; | Obtains the UID array of applications that are on the power-saving allowlist. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function on(type: "netUidPolicyChange", callback: Callback\<{ uid: number, policy: NetUidPolicy }>): void; | Subscribes to policy changes. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function off(type: "netUidPolicyChange", callback: Callback\<{ uid: number, policy: NetUidPolicy }>): void; | Unsubscribes from policy changes. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function on(type: "netUidRuleChange", callback: Callback\<{ uid: number, rule: NetUidRule }>): void; | Subscribes to rule changes. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function off(type: "netUidRuleChange", callback: Callback\<{ uid: number, rule: NetUidRule }>): void; | Unsubscribes from rule changes. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function on(type: "netMeteredIfacesChange", callback: Callback\>): void; | Subscribes to metered **iface** changes. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function off(type: "netMeteredIfacesChange", callback: Callback\>): void; | Unsubscribes from metered **iface** changes. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function on(type: "netQuotaPolicyChange", callback: Callback\>): void; | Subscribes to network quota policy changes. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function off(type: "netQuotaPolicyChange", callback: Callback\>): void; | Unsubscribes from network quota policy changes. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function on(type: "netBackgroundPolicyChange", callback: Callback\): void; | Subscribes to background network policy changes. This API uses an asynchronous callback to return the result.| -| ohos.net.policy | function off(type: "netBackgroundPolicyChange", callback: Callback\): void; | Unsubscribes from background network policy changes. This API uses an asynchronous callback to return the result.| - -## Managing the Metering Network Policy - -1. Import the **policy** namespace from **@ohos.net.policy.d.ts**. - -2. Call **setNetQuotaPolicies** to configure the metering network policy. - -3. Call **getNetQuotaPolicies** to obtain the configured metering network policy. - -```js - // Import the policy namespace. - import policy from '@ohos.net.policy'; - - addNetQuotaPolicy(){ - let param = { - // For details about the value of netType, see [NetBearType](../reference/apis/js-apis-net-connection.md#netbeartype). - netType:Number.parseInt(this.netType), - - // Integrated circuit card identifier (ICCID) of the SIM card on the metering cellular network. It is not available for an Ethernet or Wi-Fi network. - iccid:this.iccid, - - // Used together with ICCID on the metering cellular network. It is used independently on an Ethernet or Wi-Fi network. - ident:this.ident, - - // Metering start time, for example, M1, D1, and Y1. - periodDuration:this.periodDuration, - - // Set the traffic threshold for generating an alarm to an integer greater than 0. - warningBytes:Number.parseInt(this.warningBytes), - - // Set the traffic quota to an integer greater than 0. - limitBytes:Number.parseInt(this.limitBytes), - - // Specify whether the network is a metering network. The value true means a metering network and false means a non-metering network. - metered:Boolean(Number.parseInt(this.metered)),https://gitee.com/openharmony/docs/pulls/14404 - // For details about the action triggered after the traffic limit is reached, see [LimitAction](../reference/apis/js-apis-net-policy.md#limitaction). - limitAction:Number.parseInt(this.limitAction) - }; - this.netQuotaPolicyList.push(param); - }, - - // Subscribe to metered iface changes. - policy.on('netMeteredIfacesChange', (data) => { - this.log('on netMeteredIfacesChange: ' + JSON.stringify(data)); - }); - - // Subscribe to metering network policy changes. - policy.on('netQuotaPolicyChange', (data) => { - this.log('on netQuotaPolicyChange: ' + JSON.stringify(data)); - }); - - // Call setNetQuotaPolicies to configure the metering network policy. - setNetQuotaPolicies(){ - this.dialogType = DialogType.HIDE; - policy.setNetQuotaPolicies(this.netQuotaPolicyList, (err, data) => { - console.log(JSON.stringify(err)); - console.log(JSON.stringify(data)); - }); - }, - - // Call getNetQuotaPolicies to obtain the configured metering network policy. - getNetQuotaPolicies(){ - policy.getNetQuotaPolicies((err, data) => { - this.callBack(err, data); - if(data){ - this.netQuotaPolicyList = data; - } - }); - }, - - // Unsubscribe from metered iface changes. - policy.off('netMeteredIfacesChange', (data) => { - this.log('off netMeteredIfacesChange: ' + JSON.stringify(data)); - }); - - // Unsubscribe from metering network policy changes. - policy.off('netQuotaPolicyChange', (data) => { - this.log('off netQuotaPolicyChange: ' + JSON.stringify(data)); - }); -``` - -## Managing Network Access for an Application in the Background - -### How to Develop - -1. Import the **policy** namespace from **@ohos.net.policy.d.ts**. - -2. Call **setBackgroundAllowed** to enable or disable the background network restriction switch. - -3. Call **isBackgroundAllowed** to check whether the background network restriction switch is enabled or disabled. - -4. Call **getBackgroundPolicyByUid** to check whether the application indicated b the specified UID can access the network in the background. - -```js - // Import the policy namespace. - import policy from '@ohos.net.policy' - - // Subscribe to background network policy changes. - policy.on('netBackgroundPolicyChange', (data) => { - this.log('on netBackgroundPolicyChange: ' + JSON.stringify(data)); - }); - - // Call setBackgroundAllowed to enable or disable the background network restriction switch. - setBackgroundAllowed() { - policy.setBackgroundAllowed(Boolean(Number.parseInt(this.isBoolean)), (err, data) => { - console.log(JSON.stringify(err)); - console.log(JSON.stringify(data)) - }); - }, - - // Call isBackgroundAllowed to check whether the background network restriction switch is enabled or disabled. - isBackgroundAllowed() { - policy.isBackgroundAllowed((err, data) => { - console.log(JSON.stringify(err)); - console.log(JSON.stringify(data)) - }); - }, - - // Call getBackgroundPolicyByUid to check whether the application indicated b the specified UID can access the network in the background. - getBackgroundPolicyByUid() { - policy.getBackgroundPolicyByUid(Number.parseInt(this.firstParam), (err, data) => { - console.log(JSON.stringify(err)); - console.log(JSON.stringify(data)) - }); - }, - - // Unsubscribe from background network policy changes. - policy.off('netBackgroundPolicyChange', (data) => { - this.log('off netBackgroundPolicyChange: ' + JSON.stringify(data)); - }); -``` - -## Managing the Metering Network Access Policy - -### How to Develop - -1. Import the **policy** namespace from **@ohos.net.policy.d.ts**. - -2. Call **setPolicyByUid** to set whether the application indicated by the specified UID can access the network in the background. - -3. Call **getPolicyByUid** to check whether the metering network access policy for the application indicated by the specified UID. - -4. Call **getUidsByPolicy** to obtain the UIDs of the applications for which the metering network access policy is configured. - -```js - // Import the policy namespace. - import policy from '@ohos.net.policy' - - // Subscribe to policy changes of the application indicated by the specified UID. - policy.on('netUidPolicyChange', (data) => { - this.log('on netUidPolicyChange: ' + JSON.stringify(data)); - }); - - // Subscribe to rule changes of the application indicated by the specified UID. - policy.on('netUidRuleChange', (data) => { - this.log('on netUidRuleChange: ' + JSON.stringify(data)); - }); - - // Call setPolicyByUid to set whether the application indicated by the specified UID can access the network in the background. - setPolicyByUid() { - let param = { - uid: Number.parseInt(this.firstParam), policy: Number.parseInt(this.currentNetUidPolicy) - } - policy.setPolicyByUid(Number.parseInt(this.firstParam), Number.parseInt(this.currentNetUidPolicy), (err, data) => { - console.log(JSON.stringify(err)); - console.log(JSON.stringify(data)) - }); - }, - - // Call getPolicyByUid to check whether the metering network access policy for the application indicated by the specified UID. - getPolicyByUid() { - policy.getPolicyByUid(Number.parseInt(this.firstParam), (err, data) => { - console.log(JSON.stringify(err)); - console.log(JSON.stringify(data)) - }); - }, - - // Call getUidsByPolicy to obtain the UIDs of the applications for which the metering network access policy is configured. - getUidsByPolicy(){ - policy.getUidsByPolicy(Number.parseInt(this.currentNetUidPolicy), (err, data) => { - console.log(JSON.stringify(err)); - console.log(JSON.stringify(data)) - }); - }, - - // Unsubscribe from policy changes of the application indicated by the specified UID. - policy.off('netUidPolicyChange', (data) => { - this.log('off netUidPolicyChange: ' + JSON.stringify(data)); - }); - - // Unsubscribe from rule changes of the application indicated by the specified UID. - policy.off('netUidRuleChange', (data) => { - this.log('off netUidRuleChange: ' + JSON.stringify(data)); - }); - -``` - -## Restoring Network Policies - -### How to Develop - -1. Import the **policy** namespace from **@ohos.net.policy.d.ts**. - -2. Call **restoreAllPolicies** to restore all network policies. - -```js - // Import the policy namespace. - import policy from '@ohos.net.policy' - - // Call restoreAllPolicies to restore all network policies. - restoreAllPolicies(){ - policy.restoreAllPolicies(this.firstParam, (err, data) => { - console.log(JSON.stringify(err)); - console.log(JSON.stringify(data)) - }); - }, -``` - -## Checking Access to a Metering or Non-metering Network - -### How to Develop - -1. Import the **policy** namespace from **@ohos.net.policy.d.ts**. - -2. Call **isUidNetAllowed** to check whether the UID can access the metering or non-metering network. - -```js - // Import the policy namespace. - import policy from '@ohos.net.policy' - - // Call isUidNetAllowed to check whether the application indicated by the specified UID can access the metering or non-metering network. - isUidNetAllowedIsMetered(){ - let param = { - uid: Number.parseInt(this.firstParam), isMetered: Boolean(Number.parseInt(this.isBoolean)) - } - policy.isUidNetAllowed(Number.parseInt(this.firstParam), Boolean(Number.parseInt(this.isBoolean)), (err, data) => { - console.log(JSON.stringify(err)); - console.log(JSON.stringify(data)) - }); - }, -``` - -## Managing the Sleep Mode Allowlist - -### How to Develop - -1. Import the **policy** namespace from **@ohos.net.policy.d.ts**. - -2. Call **setDeviceIdleAllowList** to add a UID to or remove a UID from the sleep mode allowlist. - -3. Call **getDeviceIdleAllowList** to obtain the UIDs added to the sleep mode allowlist. - -```js - // Import the policy namespace. - import policy from '@ohos.net.policy' - - // Call setDeviceIdleAllowList to add a UID to or remove a UID from the sleep mode allowlist. - setDeviceIdleAllowList(){ - let param = { - uid: Number.parseInt(this.firstParam), isAllowed: Boolean(Number.parseInt(this.isBoolean)) - } - policy.setDeviceIdleAllowList(Number.parseInt(this.firstParam), Boolean(Number.parseInt(this.isBoolean)), (err, data) => { - console.log(JSON.stringify(err)); - console.log(JSON.stringify(data)) - }); - }, - - // Call getDeviceIdleAllowList to obtain the UIDs added to the sleep mode allowlist. - getDeviceIdleAllowList(){ - policy.getDeviceIdleAllowList((err, data) => { - console.log(JSON.stringify(err)); - console.log(JSON.stringify(data)) - }); - }, -``` - -## Managing the Power-saving Mode Allowlist - -### How to Develop - -1. Import the **policy** namespace from **@ohos.net.policy.d.ts**. -2. Call **setPowerSaveAllowList** to add a UID to or remove a UID from the power-saving mode allowlist. -3. Call **getPowerSaveAllowList** to obtain the UIDs added to the power-saving mode allowlist. - -```js - // Import the policy namespace. - import policy from '@ohos.net.policy' - - // Call setPowerSaveAllowList to add a UID to or remove a UID from the power-saving mode allowlist. - setPowerSaveAllowList(){ - let param = { - uid: Number.parseInt(this.firstParam), isAllowed: Boolean(Number.parseInt(this.isBoolean)) - } - policy.setPowerSaveAllowList(Number.parseInt(this.firstParam), Boolean(Number.parseInt(this.isBoolean)), (err, data) => { - console.log(JSON.stringify(err)); - console.log(JSON.stringify(data)) - }); - }, - - // Call getPowerSaveAllowList to obtain the UIDs added to the power-saving mode allowlist. - getPowerSaveAllowList(){ - policy.getPowerSaveAllowList((err, data) => { - console.log(JSON.stringify(err)); - console.log(JSON.stringify(data)) - }); - }, -``` - -## Updating the Network Notification Policy - -### How to Develop - -1. Import the **policy** namespace from **@ohos.net.policy.d.ts**. - -2. Call **updateRemindPolicy** to update the network notification policy. - -```js - // Import the policy namespace. - import policy from '@ohos.net.policy' - - // Call updateRemindPolicy to update the network notification policy. - updateRemindPolicy() { - let param = { - netType: Number.parseInt(this.netType), iccid: this.firstParam, remindType: this.currentRemindType - } - policy.updateRemindPolicy(Number.parseInt(this.netType), this.firstParam, Number.parseInt(this.currentRemindType), (err, data) => { - console.log(JSON.stringify(err)); - console.log(JSON.stringify(data)) - }); - }, -``` diff --git a/en/application-dev/reference/apis/Readme-EN.md b/en/application-dev/reference/apis/Readme-EN.md index b942d5aa2a..1a65db36ed 100644 --- a/en/application-dev/reference/apis/Readme-EN.md +++ b/en/application-dev/reference/apis/Readme-EN.md @@ -344,6 +344,7 @@ - [@ohos.multimodalInput.mouseEvent (Mouse Event)](js-apis-mouseevent.md) - [@ohos.multimodalInput.pointer (Mouse Pointer)](js-apis-pointer.md) - [@ohos.multimodalInput.touchEvent (Touch Event)](js-apis-touchevent.md) + - [@ohos.multimodalInput.shortKey (Shortcut Key)](js-apis-shortKey.md) - [@ohos.power (System Power Management)](js-apis-power.md) - [@ohos.runningLock (Runninglock)](js-apis-runninglock.md) - [@ohos.sensor (Sensor)](js-apis-sensor.md) diff --git a/en/application-dev/reference/apis/js-apis-call.md b/en/application-dev/reference/apis/js-apis-call.md index 1f90664de2..a488a313be 100644 --- a/en/application-dev/reference/apis/js-apis-call.md +++ b/en/application-dev/reference/apis/js-apis-call.md @@ -2057,7 +2057,7 @@ promise.then(data => { setCallWaiting\(slotId: number, activate: boolean, callback: AsyncCallback\\): void -Sets the call waiting switch. This API uses an asynchronous callback to return the result. +Specifies whether to enable the call waiting service. This API uses an asynchronous callback to return the result. **System API**: This is a system API. @@ -2099,7 +2099,7 @@ call.setCallWaiting(0, true, (err) => { setCallWaiting\(slotId: number, activate: boolean\): Promise\ -Sets the call waiting switch. This API uses a promise to return the result. +Specifies whether to enable the call waiting service. This API uses a promise to return the result. **System API**: This is a system API. @@ -2719,6 +2719,91 @@ call.off('mmiCodeResult', data => { }); ``` + +## call.on('audioDeviceChange')10+ + +on\(type: 'audioDeviceChange', callback: Callback\\): void + +Subscribes to audio device change events. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permission**: ohos.permission.SET_TELEPHONY_STATE + +**System capability**: SystemCapability.Telephony.CallManager + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------------------------------- | ---- | --------------------------------------------------- | +| type | string | Yes | Audio device change. This field has a fixed value of **audioDeviceChange**.| +| callback | Callback<[AudioDeviceInfo](#audiodeviceinfo10)> | Yes | Callback used to return the result. | + +**Error codes** + +For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + +| ID| Error Message | +| -------- | -------------------------------------------- | +| 201 | Permission denied. | +| 202 | Non-system applications use system APIs. | +| 401 | Parameter error. | +| 8300001 | Invalid parameter value. | +| 8300002 | Operation failed. Cannot connect to service. | +| 8300003 | System internal error. | +| 8300999 | Unknown error code. | + +**Example** + +```js +call.on('audioDeviceChange', data => { + console.log(`callback: data->${JSON.stringify(data)}`); +}); +``` + + +## call.off('audioDeviceChange')10+ + +off\(type: 'audioDeviceChange', callback?: Callback\\): void + +Unsubscribes from **audioDeviceChange** events. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permission**: ohos.permission.SET_TELEPHONY_STATE + +**System capability**: SystemCapability.Telephony.CallManager + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------------------------- | ---- | --------------------------------------------------- | +| type | string | Yes | Audio device change. This field has a fixed value of **audioDeviceChange**.| +| callback | Callback<[AudioDeviceInfo](#audiodeviceinfo10)> | No | Callback used to return the result. If this parameter is not set, no subscription cancellation result will be received. | + +**Error codes** + +For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + +| ID| Error Message | +| -------- | -------------------------------------------- | +| 201 | Permission denied. | +| 202 | Non-system applications use system APIs. | +| 401 | Parameter error. | +| 8300001 | Invalid parameter value. | +| 8300002 | Operation failed. Cannot connect to service. | +| 8300003 | System internal error. | +| 8300999 | Unknown error code. | + +**Example** + +```js +call.off('audioDeviceChange', data => { + console.log(`callback: data->${JSON.stringify(data)}`); +}); +``` + + ## call.isNewCallAllowed8+ isNewCallAllowed\(callback: AsyncCallback\\): void @@ -3804,7 +3889,7 @@ call.updateImsCallMode(1, 1).then(() => { enableImsSwitch\(slotId: number, callback: AsyncCallback\\): void -Enables the IMS switch. This API uses an asynchronous callback to return the result. +Enables the IMS service. This API uses an asynchronous callback to return the result. **System API**: This is a system API. @@ -3845,7 +3930,7 @@ call.enableImsSwitch(0, (err) => { enableImsSwitch\(slotId: number\): Promise\ -Enables the IMS switch. This API uses a promise to return the result. +Enables the IMS service. This API uses a promise to return the result. **System API**: This is a system API. @@ -3893,7 +3978,7 @@ call.enableImsSwitch(0).then(() => { disableImsSwitch\(slotId: number, callback: AsyncCallback\\): void -Disables the IMS switch. This API uses an asynchronous callback to return the result. +Disables the IMS service. This API uses an asynchronous callback to return the result. **System API**: This is a system API. @@ -3934,7 +4019,7 @@ call.disableImsSwitch(0, (err) => { disableImsSwitch\(slotId: number\): Promise\ -Disables the IMS switch. This API uses a promise to return the result. +Disables the IMS service. This API uses a promise to return the result. **System API**: This is a system API. @@ -3982,7 +4067,7 @@ call.disableImsSwitch(0).then(() => { isImsSwitchEnabled\(slotId: number, callback: AsyncCallback\\): void -Checks whether the IMS switch is enabled. This API uses an asynchronous callback to return the result. +Checks whether the IMS service is enabled. This API uses an asynchronous callback to return the result. **System API**: This is a system API. @@ -4020,7 +4105,7 @@ call.isImsSwitchEnabled(0, (err, data) => { isImsSwitchEnabled\(slotId: number\): Promise\ -Checks whether the IMS switch is enabled. This API uses a promise to return the result. +Checks whether the IMS service is enabled. This API uses a promise to return the result. **System API**: This is a system API. @@ -4062,6 +4147,472 @@ promise.then(data => { }); ``` + +## call.closeUnfinishedUssd10+ + +closeUnfinishedUssd\(slotId: number, callback: AsyncCallback\\): void + +Cancels the unfinished USSD services. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permission**: ohos.permission.SET_TELEPHONY_STATE + +**System capability**: SystemCapability.Telephony.CallManager + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | -------------------------------------- | +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 | +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | + +**Error codes** + +For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + +| ID| Error Message | +| -------- | -------------------------------------------- | +| 201 | Permission denied. | +| 202 | Non-system applications use system APIs. | +| 401 | Parameter error. | +| 8300001 | Invalid parameter value. | +| 8300002 | Operation failed. Cannot connect to service. | +| 8300003 | System internal error. | +| 8300999 | Unknown error code. | + +**Example** + +```js +let slotId = 0; +call.closeUnfinishedUssd(slotId, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); +}); +``` + +## call.closeUnfinishedUssd10+ + +closeUnfinishedUssd\(slotId: number\): Promise\ + +Cancels the unfinished USSD services. This API uses a promise to return the result. + +**System API**: This is a system API. + +**Required permission**: ohos.permission.SET_TELEPHONY_STATE + +**System capability**: SystemCapability.Telephony.CallManager + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | -------------------------------------- | +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 | + +**Return value** + +| Type | Description | +| ------------------- | --------------------------- | +| Promise<void> | Promise used to return the result. | + +**Error codes** + +For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + +| ID| Error Message | +| -------- | -------------------------------------------- | +| 201 | Permission denied. | +| 202 | Non-system applications use system APIs. | +| 401 | Parameter error. | +| 8300001 | Invalid parameter value. | +| 8300002 | Operation failed. Cannot connect to service. | +| 8300003 | System internal error. | +| 8300999 | Unknown error code. | + +**Example** + +```js +let slotId = 0; +call.closeUnfinishedUssd(slotId).then(() => { + console.log(`closeUnfinishedUssd success.`); +}).catch((err) => { + console.error(`closeUnfinishedUssd fail, promise: err->${JSON.stringify(err)}`); +}); +``` + + +## call.setVoNRState10+ + +setVoNRState\(slotId: number, state: VoNRState, callback: AsyncCallback\\): void + +Sets the status of the VoNR switch. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permission**: ohos.permission.SET_TELEPHONY_STATE + +**System capability**: SystemCapability.Telephony.CallManager + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | ----------------------------- | ---- | ---------------------------------------------------- | +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 | +| state | [VoNRState](#vonrstate10) | Yes | Status of the VoNR switch. | +| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. Callback used to return the result. The value **true** indicates that the operation is successful, and value **false** indicates the opposite.| + +**Error codes** + +For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + +| ID| Error Message | +| -------- | -------------------------------------------- | +| 201 | Permission denied. | +| 202 | Non-system applications use system APIs. | +| 401 | Parameter error. | +| 8300001 | Invalid parameter value. | +| 8300002 | Operation failed. Cannot connect to service. | +| 8300003 | System internal error. | +| 8300999 | Unknown error code. | + +**Example** + +```js +let slotId = 0; +let state = 1; +call.setVoNRState(slotId, state, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## call.setVoNRState10+ + +setVoNRState\(slotId: number, state: VoNRState\): Promise\ + +Sets the status of the VoNR switch. This API uses a promise to return the result. + +**System API**: This is a system API. + +**Required permission**: ohos.permission.SET_TELEPHONY_STATE + +**System capability**: SystemCapability.Telephony.CallManager + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | ----------------------------- | ---- | ------------------------------------------- | +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 | +| state | [VoNRState](#vonrstate10) | Yes | Status of the VoNR switch. | + +**Return value** + +| Type | Description | +| ---------------------- | --------------------------------------------- | +| Promise<boolean> | Promise used to return the result. | + +**Error codes** + +For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + +| ID| Error Message | +| -------- | -------------------------------------------- | +| 201 | Permission denied. | +| 202 | Non-system applications use system APIs. | +| 401 | Parameter error. | +| 8300001 | Invalid parameter value. | +| 8300002 | Operation failed. Cannot connect to service. | +| 8300003 | System internal error. | +| 8300999 | Unknown error code. | + +**Example** + +```js +let slotId = 0; +let state = 1; +call.setVoNRState(slotId, state).then(() => { + console.log(`setVoNRState success, promise: data->${JSON.stringify(data)}`); +}).catch((err) => { + console.error(`setVoNRState fail, promise: err->${JSON.stringify(err)}`); +}); +``` + + +## call.getVoNRState10+ + +getVoNRState\(slotId: number, callback: AsyncCallback\\): void + +Obtains the status of the VoNR switch. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permission**: ohos.permission.GET_TELEPHONY_STATE + +**System capability**: SystemCapability.Telephony.CallManager + +**Parameters** + +| Name | Type | Mandatory | Description | +| ----------- | --------------------------------------------- | ---- | ------------------------------------------------------ | +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 | +| callback | AsyncCallback<[VoNRState](#vonrstate10)>| Yes | Callback used to return the result. | + +**Error codes** + +For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + +| ID| Error Message | +| -------- | -------------------------------------------- | +| 201 | Permission denied. | +| 202 | Non-system applications use system APIs. | +| 401 | Parameter error. | +| 8300001 | Invalid parameter value. | +| 8300002 | Operation failed. Cannot connect to service. | +| 8300003 | System internal error. | +| 8300999 | Unknown error code. | + +**Example** + +```js +let slotId = 0; +call.getVoNRState(slotId, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## call.getVoNRState10+ + +getVoNRState\(slotId: number\): Promise\ + +Obtains the status of the VoNR switch. This API uses a promise to return the result. + +**System API**: This is a system API. + +**Required permission**: ohos.permission.GET_TELEPHONY_STATE + +**System capability**: SystemCapability.Telephony.CallManager + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | ----------------------------- | ---- | ------------------------------------------- | +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 | + +**Return value** + +| Type | Description | +| ---------------------------------------- | ------------------------------------------- | +| Promise<[VoNRState](#vonrstate10)> | Promise used to return the result. | + +**Error codes** + +For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + +| ID| Error Message | +| -------- | -------------------------------------------- | +| 201 | Permission denied. | +| 202 | Non-system applications use system APIs. | +| 401 | Parameter error. | +| 8300001 | Invalid parameter value. | +| 8300002 | Operation failed. Cannot connect to service. | +| 8300003 | System internal error. | +| 8300999 | Unknown error code. | + +**Example** + +```js +let slotId = 0; +let promise = call.getVoNRState(slotId); +promise.then(data => { + console.log(`getVoNRState success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`getVoNRState fail, promise: err->${JSON.stringify(err)}`); +}); +``` + + +## call.canSetCallTransferTime10+ + +canSetCallTransferTime\(slotId: number, callback: AsyncCallback\\): void + +Checks whether the call forwarding time can be set. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permission**: ohos.permission.GET_TELEPHONY_STATE + +**System capability**: SystemCapability.Telephony.CallManager + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | ----------------------------- | ---- | ----------------------------------------------------- | +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 | +| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. Callback used to return the result. The value **true** indicates that the call forwarding time can be set, and the value **false** indicates the opposite.| + +**Error codes** + +For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + +| ID| Error Message | +| -------- | -------------------------------------------- | +| 201 | Permission denied. | +| 202 | Non-system applications use system APIs. | +| 401 | Parameter error. | +| 8300001 | Invalid parameter value. | +| 8300002 | Operation failed. Cannot connect to service. | +| 8300003 | System internal error. | +| 8300999 | Unknown error code. | + +**Example** + +```js +let slotId = 0; +call.canSetCallTransferTime(slotId, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## call.canSetCallTransferTime10+ + +canSetCallTransferTime\(slotId: number\): Promise\ + +Checks whether the call forwarding time can be set. This API uses a promise to return the result. + +**System API**: This is a system API. + +**Required permission**: ohos.permission.GET_TELEPHONY_STATE + +**System capability**: SystemCapability.Telephony.CallManager + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | ----------------------------- | ---- | ------------------------------------------- | +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 | + +**Return value** + +| Type | Description | +| ---------------------- | --------------------------------------------- | +| Promise<boolean> | Promise used to return the result.| + +**Error codes** + +For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + +| ID| Error Message | +| -------- | -------------------------------------------- | +| 201 | Permission denied. | +| 202 | Non-system applications use system APIs. | +| 401 | Parameter error. | +| 8300001 | Invalid parameter value. | +| 8300002 | Operation failed. Cannot connect to service. | +| 8300003 | System internal error. | +| 8300999 | Unknown error code. | + +**Example** + +```js +let slotId = 0; +call.canSetCallTransferTime(slotId).then(() => { + console.log(`canSetCallTransferTime success, promise: data->${JSON.stringify(data)}`); +}).catch((err) => { + console.error(`canSetCallTransferTime fail, promise: err->${JSON.stringify(err)}`); +}); +``` + + +## call.inputDialerSpecialCode10+ + +inputDialerSpecialCode\(inputCode: string, callback: AsyncCallback\\): void + +Performs a secret code broadcast. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required Permissions**: ohos.permission.PLACE_CALL + +**System capability**: SystemCapability.Telephony.CallManager + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | ---------------------------- | ---- | ----------------------------------------- | +| inputCode | string | Yes | Secret code, for example, **2846579** (project menu).| +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | + +**Error codes** + +For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + +| ID| Error Message | +| -------- | -------------------------------------------- | +| 201 | Permission denied. | +| 202 | Non-system applications use system APIs. | +| 401 | Parameter error. | +| 8300001 | Invalid parameter value. | +| 8300002 | Operation failed. Cannot connect to service. | +| 8300003 | System internal error. | + +**Example** + +```js +call.inputDialerSpecialCode('2846579', (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); +}); +``` + +## call.inputDialerSpecialCode10+ + +inputDialerSpecialCode\(inputCode: string\): Promise\ + +Performs a secret code broadcast. This API uses a promise to return the result. + +**System API**: This is a system API. + +**Required Permissions**: ohos.permission.PLACE_CALL + +**System capability**: SystemCapability.Telephony.CallManager + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | ---------------------------- | ---- | ----------------------------------------- | +| inputCode | string | Yes | Secret code, for example, **2846579** (project menu).| + +**Return value** + +| Type | Description | +| ------------------- | --------------------------- | +| Promise<void> | Promise used to return the result.| + +**Error codes** + +For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + +| ID| Error Message | +| -------- | -------------------------------------------- | +| 201 | Permission denied. | +| 202 | Non-system applications use system APIs. | +| 401 | Parameter error. | +| 8300001 | Invalid parameter value. | +| 8300002 | Operation failed. Cannot connect to service. | +| 8300003 | System internal error. | + +**Example** + +```js +try { + call.inputDialerSpecialCode('2846579'); + console.log(`inputDialerSpecialCode success`); +} catch (error) { + console.log(`inputDialerSpecialCode fail, promise: err->${JSON.stringify(error)}`); +} +``` + + ## DialOptions Provides an option for determining whether a call is a video call. @@ -4071,23 +4622,25 @@ Provides an option for determining whether a call is a video call. | Name | Type | Mandatory| Description | | ------------------------ | ---------------------------------- | ---- | ----------------------------------------------------------------------------------------------- | | extras | boolean | No | Indication of a video call.
- **true**: video call
- **false** (default): voice call | -| accountId 8+ | number | No | Account ID.
- **0**: card slot 1
- **1**: card slot 2
| -| videoState 8+ | [VideoStateType](#videostatetype7) | No | Video state type. | -| dialScene 8+ | [DialScene](#dialscene8) | No | Dialup scenario. | -| dialType 8+ | [DialType](#dialtype8) | No | Dialup type. | +| accountId 8+ | number | No | Account ID.
- **0**: card slot 1
- **1**: card slot 2
This is a system API. | +| videoState 8+ | [VideoStateType](#videostatetype7) | No | Video state type. This is a system API. | +| dialScene 8+ | [DialScene](#dialscene8) | No | Dialup scenario. This is a system API. | +| dialType 8+ | [DialType](#dialtype8) | No | Dialup type. This is a system API. | ## DialCallOptions9+ Defines options for initiating a call. +**System API**: This is a system API. + **System capability**: SystemCapability.Telephony.CallManager -| Name | Type | Mandatory| Description | -| ------------------------ | ---------------------------------- | ---- | ------------------------------------------------------------ | -| accountId 9+ | number | No | Account ID.
- **0**: card slot 1
- **1**: card slot 2
This is a system API.| -| videoState 9+ | [VideoStateType](#videostatetype7) | No | Video state type. This is a system API. | -| dialScene 9+ | [DialScene](#dialscene8) | No | Dialup scenario. This is a system API. | -| dialType 9+ | [DialType](#dialtype8) | No | Dialup type. This is a system API. | +| Name | Type | Mandatory| Description | +| ------------------------ | ---------------------------------- | ---- | ------------------------------------------- | +| accountId 9+ | number | No | Account ID.
- **0**: card slot 1
- **1**: card slot 2
| +| videoState 9+ | [VideoStateType](#videostatetype7) | No | Video state type. | +| dialScene 9+ | [DialScene](#dialscene8) | No | Dialup scenario. | +| dialType 9+ | [DialType](#dialtype8) | No | Dialup type. | ## CallState @@ -4138,6 +4691,19 @@ Enumerates IMS call modes. | CALL_MODE_SEND_RECEIVE | 3 | Sending and receiving calls.| | CALL_MODE_VIDEO_PAUSED | 4 | Pausing video calls. | +## VoNRState10+ + +Enumerates VoNR switch states. + +**System API**: This is a system API. + +**System capability**: SystemCapability.Telephony.CallManager + +| Name | Value | Description | +| ---------------------- | ---- | ----------------- | +| VONR_STATE_OFF | 0 | Disabled. | +| VONR_STATE_ON | 1 | Enabled. | + ## AudioDevice8+ Enumerates audio devices. @@ -4154,6 +4720,36 @@ Enumerates audio devices. | DEVICE_BLUETOOTH_SCO | 3 | Bluetooth SCO device. | | DEVICE_MIC | 4 | Microphone device| +## AudioDeviceType10+ + +Enumerates audio device types. + +**System API**: This is a system API. + +**System capability**: SystemCapability.Telephony.CallManager + +| Name | Value | Description | +| -------------------- | ---- | ----------- | +| DEVICE_EARPIECE | 0 | Headset device. | +| DEVICE_SPEAKER | 1 | Speaker device. | +| DEVICE_WIRED_HEADSET | 2 | Wired headset device.| +| DEVICE_BLUETOOTH_SCO | 3 | Bluetooth SCO device. | + +## AudioDeviceInfo10+ + +Defines the audio device information. + +**System API**: This is a system API. + +**System capability**: SystemCapability.Telephony.CallManager + +| Name | Type | Mandatory | Description | +| --------------------------------- | ------------------------------------- | ---- | ---------------- | +| audioDeviceList 10+ | [Array\](#audiodevice8) | Yes | Audio device list. | +| currentAudioDevice 10+ | [AudioDevice](#audiodevice8) | Yes | Audio device type. | +| isMuted 10+ | boolean | Yes | Whether the audio device is muted. | + + ## CallRestrictionType8+ Enumerates call restriction types. @@ -4511,7 +5107,7 @@ Enumerates call disconnection causes. | BEARER_SERVICE_NOT_IMPLEMENTED9+ | 65 | Bearer service not implemented. | | ACM_EQUALTO_OR_GREATER_THAN_THE_MAXIMUM_VALUE9+ | 68 | ACM greater than or equal to the maximum value. | | REQUESTED_FACILITY_NOT_IMPLEMENTED9+ | 69 | Requested facility not implemented. | -| ONLY_RESTRICTED_DIGITAL_INFO_BEARER_CAPABILITY_IS_AVAILABLE9+ | 70 | Only restricted digital information capability available. | +| ONLY_RESTRICTED_DIGITAL_INFO_BEARER_CAPABILITY_IS_AVAILABLE9+ | 70 | Only restricted digital information bearer capability available. | | SERVICE_OR_OPTION_NOT_IMPLEMENTED_UNSPECIFIED9+ | 79 | Service or option not implemented, unspecified. | | INVALID_TRANSACTION_IDENTIFIER_VALUE9+ | 81 | Invalid transaction identifier value. | | USER_NOT_MEMBER_OF_CUG9+ | 87 | User not member of CUG. | diff --git a/en/application-dev/reference/apis/js-apis-i18n.md b/en/application-dev/reference/apis/js-apis-i18n.md index db85444d68..fe9a116b82 100644 --- a/en/application-dev/reference/apis/js-apis-i18n.md +++ b/en/application-dev/reference/apis/js-apis-i18n.md @@ -46,7 +46,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod | ID | Error Message | | ------ | ---------------------- | -| 890001 | Unspported para value. | +| 890001 | param value not valid | **Example** ```js @@ -85,7 +85,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod | ID | Error Message | | ------ | ---------------------- | -| 890001 | Unspported para value. | +| 890001 | param value not valid | **Example** ```js @@ -116,7 +116,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod | ID | Error Message | | ------ | ---------------------- | -| 890001 | Unspported para value. | +| 890001 | param value not valid | **Example** ```js @@ -153,7 +153,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod | ID | Error Message | | ------ | ---------------------- | -| 890001 | Unspported para value. | +| 890001 | param value not valid | **Example** ```js @@ -191,7 +191,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod | ID | Error Message | | ------ | ---------------------- | -| 890001 | Unspported para value. | +| 890001 | param value not valid | **Example** ```js @@ -222,7 +222,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod | ID | Error Message | | ------ | ---------------------- | -| 890001 | Unspported para value. | +| 890001 | param value not valid | **Example** ```js @@ -257,7 +257,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod | ID | Error Message | | ------ | ---------------------- | -| 890001 | Unspported para value. | +| 890001 | param value not valid | **Example** ```js @@ -288,7 +288,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod | ID | Error Message | | ------ | ---------------------- | -| 890001 | Unspported para value. | +| 890001 | param value not valid | **Example** ```js @@ -323,7 +323,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod | ID | Error Message | | ------ | ---------------------- | -| 890001 | Unspported para value. | +| 890001 | param value not valid | **Example** ```js @@ -354,7 +354,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod | ID | Error Message | | ------ | ---------------------- | -| 890001 | Unspported para value. | +| 890001 | param value not valid | **Example** ```js @@ -389,7 +389,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod | ID | Error Message | | ------ | ---------------------- | -| 890001 | Unspported para value. | +| 890001 | param value not valid | **Example** ```js @@ -420,7 +420,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod | ID | Error Message | | ------ | ---------------------- | -| 890001 | Unspported para value. | +| 890001 | param value not valid | **Example** ```js @@ -455,7 +455,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod | ID | Error Message | | ------ | ---------------------- | -| 890001 | Unspported para value. | +| 890001 | param value not valid | **Example** ```js @@ -492,7 +492,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod | ID | Error Message | | ------ | ---------------------- | -| 890001 | Unspported para value. | +| 890001 | param value not valid | **Example** ```js @@ -530,7 +530,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod | ID | Error Message | | ------ | ---------------------- | -| 890001 | Unspported para value. | +| 890001 | param value not valid | **Example** ```js @@ -563,7 +563,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod | ID | Error Message | | ------ | ---------------------- | -| 890001 | Unspported para value. | +| 890001 | param value not valid | **Example** ```js @@ -594,7 +594,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod | ID | Error Message | | ------ | ---------------------- | -| 890001 | Unspported para value. | +| 890001 | param value not valid | **Example** ```js @@ -625,7 +625,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod | ID | Error Message | | ------ | ---------------------- | -| 890001 | Unspported para value. | +| 890001 | param value not valid | **Example** ```js @@ -660,7 +660,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod | ID | Error Message | | ------ | ---------------------- | -| 890001 | Unspported para value. | +| 890001 | param value not valid | **Example** ```ts @@ -691,7 +691,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod | ID | Error Message | | ------ | ---------------------- | -| 890001 | Unspported para value. | +| 890001 | param value not valid | **Example** ```ts @@ -1737,6 +1737,35 @@ Obtains the **TimeZone** object corresponding to the specified time zone city ID let timezone = I18n.TimeZone.getTimezoneFromCity("Shanghai"); ``` +### getTimezonesByLocation10+ + +static getTimezonesByLocation(longitude: number, latitude: number): Array<TimeZone> + +Creates an array of **TimeZone** objects corresponding to the specified longitude and latitude. + +**System capability**: SystemCapability.Global.I18n + +**Parameters** + +| Name | Type | Mandatory | Description | +| --------- | ------ | ---- | ------ | +| longitude | number | Yes | Longitude. The value ranges from **-180** to **179.9**. A positive value is used for east longitude and a negative value is used for west longitude.| +| latitude | number | Yes | Latitude. The value ranges from **-90** to **89.9**. A positive value is used for north latitude and a negative value is used for south latitude.| + +**Return value** + +| Type | Description | +| -------- | ----------- | +| Array<[TimeZone](#timezone)> | Array of **TimeZone** objects.| + +**Example** + ```js + let timezoneArray = I18n.TimeZone.getTimezonesByLocation(-118.1, 34.0); + for (var i = 0; i < timezoneArray.length; i++) { + let tzId = timezoneArray[i].getID(); + } + ``` + ## Transliterator9+ diff --git a/en/application-dev/reference/apis/js-apis-intl.md b/en/application-dev/reference/apis/js-apis-intl.md index cec10d9eef..99131363c5 100644 --- a/en/application-dev/reference/apis/js-apis-intl.md +++ b/en/application-dev/reference/apis/js-apis-intl.md @@ -1,7 +1,6 @@ # @ohos.intl (Internationalization) -The **intl** module provides basic i18n capabilities, such as time and date formatting, number formatting, and string sorting, through the standard i18n APIs defined in ECMA 402. - + The **intl** module provides basic i18n capabilities, such as time and date formatting, number formatting, and string sorting, through the standard i18n APIs defined in ECMA 402. The [i18n](js-apis-i18n.md) module provides enhanced i18n capabilities through supplementary interfaces that are not defined in ECMA 402. It works with the intl module to provide a complete suite of i18n capabilities. > **NOTE** @@ -68,7 +67,7 @@ Creates a **Locale** object. | Name | Type | Mandatory | Description | | -------------------- | -------------------------------- | ---- | ---------------------------- | | locale | string | Yes | A string containing locale information, including the language, optional script, and region. For details about the international standards and combination modes for the language, script, and country or region, see [intl Development](../../internationalization/intl-guidelines.md#setting-locale-information).| -| options9+ | [LocaleOptions](#localeoptions9) | No | Options for creating the **Locale** object. | +| options | [LocaleOptions](#localeoptions6) | No | Options for creating the **Locale** object. | **Example** ```js @@ -160,9 +159,10 @@ Minimizes information of the **Locale** object. If the script and locale informa ``` -## LocaleOptions9+ +## LocaleOptions6+ Represents the locale options. +In API version 9, the attributes in **LocaleOptions** are optional. **System capability**: SystemCapability.Global.I18n @@ -207,7 +207,7 @@ Creates a **DateTimeOptions** object for the specified locale. | Name | Type | Mandatory | Description | | -------------------- | ------------------------------------ | ---- | ---------------------------- | | locale | string \| Array<string> | Yes | A string containing locale information, including the language, optional script, and region.| -| options9+ | [DateTimeOptions](#datetimeoptions9) | No | Options for creating a **DateTimeFormat** object. | +| options | [DateTimeOptions](#datetimeoptions6) | No | Options for creating a **DateTimeFormat** object. | **Example** ```js @@ -299,7 +299,7 @@ Obtains the formatting options for **DateTimeFormat** object. | Type | Description | | ------------------------------------ | ----------------------------- | -| [DateTimeOptions](#datetimeoptions9) | Formatting options for **DateTimeFormat** objects.| +| [DateTimeOptions](#datetimeoptions6) | Formatting options for **DateTimeFormat** objects.| **Example** ```js @@ -311,9 +311,10 @@ Obtains the formatting options for **DateTimeFormat** object. ``` -## DateTimeOptions9+ +## DateTimeOptions6+ Provides the options for the **DateTimeFormat** object. +In API version 9, the attributes in **DateTimeOptions** are optional. **System capability**: SystemCapability.Global.I18n @@ -371,7 +372,7 @@ Creates a **NumberFormat** object for the specified locale. | Name | Type | Mandatory | Description | | -------------------- | -------------------------------- | ---- | ---------------------------- | | locale | string \| Array<string> | Yes | A string containing locale information, including the language, optional script, and region.| -| options9+ | [NumberOptions](#numberoptions9) | No | Options for creating a **NumberFormat** object. | +| options | [NumberOptions](#numberoptions6) | No | Options for creating a **NumberFormat** object. | **Example** ```js @@ -421,7 +422,7 @@ Obtains the options of the **NumberFormat** object. | Type | Description | | -------------------------------- | --------------------------- | -| [NumberOptions](#numberoptions9) | Formatting options for **NumberFormat** objects.| +| [NumberOptions](#numberoptions6) | Formatting options for **NumberFormat** objects.| **Example** @@ -434,9 +435,10 @@ Obtains the options of the **NumberFormat** object. ``` -## NumberOptions9+ +## NumberOptions6+ Defines the device capability. +In API version 9, the attributes in **NumberOptions** are optional. **System capability**: SystemCapability.Global.I18n @@ -448,7 +450,7 @@ Defines the device capability. | currencyDisplay | string | Yes | Yes | Currency display mode. The value can be **symbol**, **narrowSymbol**, **code**, or **name**.| | unit | string | Yes | Yes | Unit name, for example, **meter**, **inch**, or **hectare**. | | unitDisplay | string | Yes | Yes | Unit display format. The value can be **long**, **short**, or **narrow**.| -| unitUsage | string | Yes | Yes | Unit usage scenario. The value can be any of the following: **default**, **area-land-agricult**, **area-land-commercl**, **area-land-residntl**, **length-person**, **length-person-small**, **length-rainfall**, **length-road**, **length-road-small**, **length-snowfall**, **length-vehicle**, **length-visiblty**, **length-visiblty-small**, **length-person-informal**, **length-person-small-informal**, **length-road-informal**, **speed-road-travel**, **speed-wind**, **temperature-person**, **temperature-weather**, **volume-vehicle-fuel**.| +| unitUsage8+ | string | Yes | Yes | Unit usage scenario. The value can be any of the following: **default**, **area-land-agricult**, **area-land-commercl**, **area-land-residntl**, **length-person**, **length-person-small**, **length-rainfall**, **length-road**, **length-road-small**, **length-snowfall**, **length-vehicle**, **length-visiblty**, **length-visiblty-small**, **length-person-informal**, **length-person-small-informal**, **length-road-informal**, **speed-road-travel**, **speed-wind**, **temperature-person**, **temperature-weather**, **volume-vehicle-fuel**.| | signDisplay | string | Yes | Yes | Number sign display format. The value can be **auto**, **never**, **always**, or **expectZero**.| | compactDisplay | string | Yes | Yes | Compact display format. The value can be **long** or **short**. | | notation | string | Yes | Yes | Number formatting specification. The value can be **standard**, **scientific**, **engineering**, or **compact**.| @@ -494,7 +496,7 @@ Creates a **Collator** object. | Name | Type | Mandatory | Description | | -------------------- | ------------------------------------ | ---- | ---------------------------- | | locale | string \| Array<string> | Yes | A string containing locale information, including the language, optional script, and region.| -| options9+ | [CollatorOptions](#collatoroptions9) | No | Options for creating a **Collator** object. | +| options | [CollatorOptions](#collatoroptions8) | No | Options for creating a **Collator** object. | **Example** ```js @@ -545,7 +547,7 @@ Returns properties reflecting the locale and collation options of a **Collator** | Type | Description | | ------------------------------------ | ----------------- | -| [CollatorOptions](#collatoroptions9) | Properties of the **Collator** object.| +| [CollatorOptions](#collatoroptions8) | Properties of the **Collator** object.| **Example** ```js @@ -557,9 +559,10 @@ Returns properties reflecting the locale and collation options of a **Collator** ``` -## CollatorOptions9+ +## CollatorOptions8+ Represents the properties of a **Collator** object. +In API version 9, the attributes in **CollatorOptions** are optional. **System capability**: SystemCapability.Global.I18n @@ -605,7 +608,7 @@ Creates a **PluralRules** object to obtain the singular-plural type of numbers. | Name | Type | Mandatory | Description | | -------------------- | ---------------------------------------- | ---- | ---------------------------- | | locale | string \| Array<string> | Yes | A string containing locale information, including the language, optional script, and region.| -| options9+ | [PluralRulesOptions](#pluralrulesoptions9) | No | Options for creating a **PluralRules** object. | +| options | [PluralRulesOptions](#pluralrulesoptions8) | No | Options for creating a **PluralRules** object. | **Example** ```js @@ -648,9 +651,10 @@ Obtains a string that represents the singular-plural type of the specified numbe ``` -## PluralRulesOptions9+ +## PluralRulesOptions8+ Represents the properties of a **PluralRules** object. +In API version 9, the attributes in **PluralRulesOptions** are optional. **System capability**: SystemCapability.Global.I18n @@ -696,7 +700,7 @@ Creates a **RelativeTimeFormat** object. | Name | Type | Mandatory | Description | | -------------------- | ---------------------------------------- | ---- | ---------------------------- | | locale | string \| Array<string> | Yes | A string containing locale information, including the language, optional script, and region.| -| options9+ | [RelativeTimeFormatInputOptions](#relativetimeformatinputoptions9) | No | Options for creating a **RelativeTimeFormat** object. | +| options | [RelativeTimeFormatInputOptions](#relativetimeformatinputoptions8) | No | Options for creating a **RelativeTimeFormat** object. | **Example** ```js @@ -788,9 +792,10 @@ Obtains the formatting options for **RelativeTimeFormat** objects. ``` -## RelativeTimeFormatInputOptions9+ +## RelativeTimeFormatInputOptions8+ Represents the properties of a **RelativeTimeFormat** object. +In API version 9, the attributes in **RelativeTimeFormatInputOptions** are optional. **System capability**: SystemCapability.Global.I18n diff --git a/en/application-dev/reference/apis/js-apis-loglibrary.md b/en/application-dev/reference/apis/js-apis-loglibrary.md new file mode 100644 index 0000000000..cbb849eab6 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-loglibrary.md @@ -0,0 +1,319 @@ +# @ohos.logLibrary (Log Library) + +The **logLibrary** module provides APIs for obtaining various system maintenance and test logs. + +> **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. +> - The APIs provided by this module are system APIs. + +## Modules to Import + +```js +import logLibrary from '@ohos.logLibrary'; +``` + +## LogEntry + +Defines a **LogEntry** object. + +**System capability**: SystemCapability.HiviewDFX.Hiview.LogLibrary + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| name | string | Yes| No| Log file name. | +| mtime | number | Yes| No | Time of the last modification to the file. The value is the number of seconds elapsed since 00:00:00 on January 1, 1970.| +| size | number | Yes| No | File size, in bytes.| + +## logLibrary.list + +list(logType: string): LogEntry[] + +Obtains the list of log files of the specified type in synchronous mode. This API accepts objects of the string type as input parameters and returns a list log files of the specified type. + +**Required permission**: ohos.permission.READ_HIVIEW_SYSTEM + +**System capability**: SystemCapability.HiviewDFX.Hiview.LogLibrary + +**Parameters** + +| Name | Type | Mandatory| Description | +| --------- | ------------------------- | ---- | ------------------------------------------------------------ | +| logType | string | Yes| Log type, for example, **HILOG**, **FAULTLOG**, **BETACLUB**, or **REMOTELOG**.| + +**Return value** + +| Type | Description | +| ------------------- | ------------------------------------------------------------ | +| LogEntry[] | Array of log file objects.| + +**Error codes** + +For details about error codes, see [Log Library Error Codes](../errorcodes/errorcode-loglibrary.md). + +| ID| Error Message| +| ------- | ----------------------------------------------------------------- | +| 201 | Permission denied. | +| 202 | Permission denied, non-system app called system api. | +| 401 | Invalid argument.| + +**Example** + +```js +import logLibrary from '@ohos.logLibrary'; + +try { + let logObj = logLibrary.list('HILOG'); + // do something here. +} catch (error) { + console.error(`error code: ${error.code}, error msg: ${error.message}`); +} +``` + +## logLibrary.copy + +copy(logType: string, logName: string, dest: string): Promise<void> + +Copies log files of the specified type to the target application directory. This API uses a promise to return the result. + +**Required permission**: ohos.permission.READ_HIVIEW_SYSTEM + +**System capability**: SystemCapability.HiviewDFX.Hiview.LogLibrary + +**Parameters** + +| Name | Type | Mandatory| Description| +| --------- | ----------------------- | ---- | --------------- | +| logType | string | Yes| Log type, for example, **HILOG**, **FAULTLOG**, **BETACLUB**, or **REMOTELOG**.| +| logName | string | Yes | Log file name.| +| dest | string | Yes | Target directory. Enter the relative path of the directory. If this parameter is specified, log files will be saved to the **hiview/dest** folder in the application cache path, that is, **../cache/hiview/dest**. You can enter a multi-level directory.
If you leave this parameter empty, log files will be saved to the root directory, that is, the **hiview** folder in the application cache path.| + +**Return value** + +| Type | Description | +| ------------------- | ------------------------------------------------------------ | +| Promise<void> | Promise used to return the result. Depending on whether the operation is successful, you can use the **then()** or **catch()** method to process the callback.| + +**Error codes** + +For details about error codes, see [Log Library Error Codes](../errorcodes/errorcode-loglibrary.md). + +| ID| Error Message| +| -------- | ---------------------------------------------------------------- | +| 201 | Permission denied. | +| 202 | Permission denied, non-system app called system api. | +| 401 | Invalid argument.| +| 21300001 | Source file does not exists. | + +**Example** + +```js +import logLibrary from '@ohos.logLibrary'; + +try { + logLibrary.copy('HILOG', 'hiapplogcat-1.zip', '' + ).then( + (val) => { + // do something here. + } + ).catch( + (err) => { + // do something here. + } + ) +} catch (error) { + console.error(`error code: ${error.code}, error msg: ${error.message}`); +} +``` + +## logLibrary.copy + +copy(logType: string, logName: string, dest: string, callback: AsyncCallback<void>): void + +Copies log files of the specified type to the target application directory. This API uses an asynchronous callback to return the result. + +**Required permission**: ohos.permission.READ_HIVIEW_SYSTEM + +**System capability**: SystemCapability.HiviewDFX.Hiview.LogLibrary + +**Parameters** + +| Name | Type | Mandatory| Description | +| --------- | ------------------------- | ---- | ------------------------------------------------------------ | +| logType | string | Yes| Log type, for example, **HILOG**, **FAULTLOG**, **BETACLUB**, or **REMOTELOG**.| +| logName | string | Yes | Log file name.| +| dest | string | Yes | Target directory. Enter the relative path of the directory. If this parameter is specified, log files will be saved to the **hiview/dest** folder in the application cache path, that is, **../cache/hiview/dest**. You can enter a multi-level directory.
If you leave this parameter empty, log files will be saved to the root directory, that is, the **hiview** folder in the application cache path.| +| callback | AsyncCallback<void> | Yes| Callback used to process the received return value. The value **0** indicates that the operation is successful, and any other value indicates that the operation has failed.| + +**Error codes** + +For details about error codes, see [Log Library Error Codes](../errorcodes/errorcode-loglibrary.md). + +| ID| Error Message| +| ------- | ----------------------------------------------------------------- | +| 201 | Permission denied. | +| 202 | Permission denied, non-system app called system api. | +| 401 | Invalid argument.| +| 21300001 | Source file does not exists. | + +**Example** + +```js +import logLibrary from '@ohos.logLibrary'; + +try { + logLibrary.copy('HILOG', 'hiapplogcat-1.zip', 'dir1', (error, val) => { + if (val === undefined) { + // copy failed. + } else { + // copy success. + } + }); +} catch (error) { + console.error(`error code: ${error.code}, error msg: ${error.message}`); +} +``` + +## logLibrary.move + +move(logType: string, logName: string, dest: string): Promise<void> + +Moves log files of the specified type to the target application directory. This API uses a promise to return the result. + +**Required permission**: ohos.permission.WRITE_HIVIEW_SYSTEM + +**System capability**: SystemCapability.HiviewDFX.Hiview.LogLibrary + +**Parameters** + +| Name | Type | Mandatory| Description| +| --------- | ----------------------- | ---- | --------------- | +| logType | string | Yes| Log type, for example, **FAULTLOG**, **BETACLUB**, or **REMOTELOG**.| +| logName | string | Yes | Log file name.| +| dest | string | Yes | Target directory. Enter the relative path of the directory. If this parameter is specified, log files will be saved to the **hiview/dest** folder in the application cache path, that is, **../cache/hiview/dest**. You can enter a multi-level directory.
If you leave this parameter empty, log files will be saved to the root directory, that is, the **hiview** folder in the application cache path.| + +**Return value** + +| Type | Description | +| ------------------- | ------------------------------------------------------------ | +| Promise<void> | Promise used to return the result. Depending on whether the operation is successful, you can use the **then()** or **catch()** method to process the callback.| + +**Error codes** + +For details about error codes, see [Log Library Error Codes](../errorcodes/errorcode-loglibrary.md). + +| ID| Error Message| +| -------- | ---------------------------------------------------------------- | +| 201 | Permission denied. | +| 202 | Permission denied, non-system app called system api. | +| 401 | Invalid argument.| +| 21300001 | Source file does not exists. | + +**Example** + +```js +import logLibrary from '@ohos.logLibrary'; + +try { + logLibrary.move('FAULTLOG', 'fault_log_test.zip', '' + ).then( + (val) => { + // do something here. + } + ).catch( + (err) => { + // do something here. + } + ) +} catch (error) { + console.error(`error code: ${error.code}, error msg: ${error.message}`); +} +``` + +## logLibrary.move + +move(logType: string, logName: string, dest: string, callback: AsyncCallback<void>): void + +Moves log files of the specified type to the target application directory. This API uses an asynchronous callback to return the result. + +**Required permission**: ohos.permission.WRITE_HIVIEW_SYSTEM + +**System capability**: SystemCapability.HiviewDFX.Hiview.LogLibrary + +**Parameters** + +| Name | Type | Mandatory| Description | +| --------- | ------------------------- | ---- | ------------------------------------------------------------ | +| logType | string | Yes| Log type, for example, **HILOG**, **FAULTLOG**, **BETACLUB**, or **REMOTELOG**.| +| logName | string | Yes | Log file name.| +| dest | string | Yes | Target directory. Enter the relative path of the directory. If this parameter is specified, log files will be saved to the **hiview/dest** folder in the application cache path, that is, **../cache/hiview/dest**. You can enter a multi-level directory.
If you leave this parameter empty, log files will be saved to the root directory, that is, the **hiview** folder in the application cache path.| +| callback | AsyncCallback<void> | Yes| Callback used to process the received return value. The value **0** indicates that the operation is successful, and any other value indicates that the operation has failed.| + +**Error codes** + +For details about error codes, see [Log Library Error Codes](../errorcodes/errorcode-loglibrary.md). + +| ID| Error Message| +| ------- | ----------------------------------------------------------------- | +| 201 | Permission denied. | +| 202 | Permission denied, non-system app called system api. | +| 401 | Invalid argument.| +| 21300001 | Source file does not exists. | + +**Example** + +```js +import logLibrary from '@ohos.logLibrary'; + +try { + logLibrary.move('FAULTLOG', 'fault_log_test.zip', 'dir1/dir2', (error, val) => { + if (val === undefined) { + // move failed. + } else { + // move success. + } + }); +} catch (error) { + console.error(`error code: ${error.code}, error msg: ${error.message}`); +} +``` + +## logLibrary.remove + +remove(logType: string, logName: string): void + +Deletes log files of the specified type in synchronous mode. + +**Required permission**: ohos.permission.WRITE_HIVIEW_SYSTEM + +**System capability**: SystemCapability.HiviewDFX.Hiview.LogLibrary + +**Parameters** + +| Name | Type | Mandatory| Description | +| --------- | ------------------------- | ---- | ------------------------------------------------------------ | +| logType | string | Yes| Log type, for example, **FAULTLOG**, **BETACLUB**, or **REMOTELOG**.| +| logName | string | Yes | Log file name.| + +**Error codes** + +For details about error codes, see [Log Library Error Codes](../errorcodes/errorcode-loglibrary.md). + +| ID| Error Message| +| ------- | ----------------------------------------------------------------- | +| 201 | Permission denied. | +| 202 | Permission denied, non-system app called system api. | +| 401 | Invalid argument.| +| 21300001 | Source file does not exists. | + +**Example** + +```js +import logLibrary from '@ohos.logLibrary'; + +try { + logLibrary.remove('FAULTLOG', 'fault_log_test.zip'); +} catch (error) { + console.error(`error code: ${error.code}, error msg: ${error.message}`); +} +``` diff --git a/en/application-dev/reference/apis/js-apis-logs.md b/en/application-dev/reference/apis/js-apis-logs.md index b2d837bae0..bda44776ef 100644 --- a/en/application-dev/reference/apis/js-apis-logs.md +++ b/en/application-dev/reference/apis/js-apis-logs.md @@ -1,8 +1,6 @@ -# console (Log Printing) +# console -The **console** module provides basic log printing capabilities and supports log printing by log level. - -If you want to use more advanced log printing services, for example, filtering logs by the specified ID, you are advised to use [`@ohos.hilog`](js-apis-hilog.md). +The **console** module provides a simple debugging console, which is similar to the JavaScript console provided by the browser. > **NOTE** > @@ -10,9 +8,9 @@ If you want to use more advanced log printing services, for example, filtering l ## console.debug -debug(message: string): void +debug(message: string, ...arguments: any[]): void -Prints debug-level logs. +Prints debugging information in formatted output mode. **System capability**: SystemCapability.ArkUI.ArkUI.Full @@ -20,14 +18,25 @@ Prints debug-level logs. | Name | Type | Mandatory | Description | | ------- | ------ | ---- | ----------- | -| message | string | Yes | Text to print.| +| message | string | Yes | Text to be printed.| +| arguments | any | No | Arguments in the message or other information to be printed.| +**Example** +```js +const number = 5; +console.debug('count: %d', number); // Print the debugging information with arguments in the message replaced. +// count: 5 +console.debug('count:', number); // Print the message and other information. +// count: 5 +console.debug('count:'); // Print the message only. +// count: +``` ## console.log -log(message: string): void +log(message: string, ...arguments: any[]): void -Prints debug-level logs. +Prints log information in formatted output mode. **System capability**: SystemCapability.ArkUI.ArkUI.Full @@ -35,14 +44,25 @@ Prints debug-level logs. | Name | Type | Mandatory | Description | | ------- | ------ | ---- | ----------- | -| message | string | Yes | Text to print.| +| message | string | Yes | Text to be printed.| +| arguments | any | No |Arguments in the message or other information to be printed.| +**Example** +```js +const number = 5; +console.log('count: %d', number); // Print the log information with arguments in the message replaced. +// count: 5 +console.log('count:', number); // Print the message and other information. +// count: 5 +console.log('count:'); // Print the message only. +// count: +``` ## console.info -info(message: string): void +info(message: string, ...arguments: any[]): void -Prints info-level logs. +Prints log information in formatted output mode. This API is the alias of **console.log ()**. **System capability**: SystemCapability.ArkUI.ArkUI.Full @@ -50,14 +70,25 @@ Prints info-level logs. | Name | Type | Mandatory | Description | | ------- | ------ | ---- | ----------- | -| message | string | Yes | Text to print.| +| message | string | Yes | Text to be printed.| +| arguments | any | No | Arguments in the message or other information to be printed.| +**Example** +```js +const number = 5; +console.info('count: %d', number); // Print the log information with arguments in the message replaced. +// count: 5 +console.info('count:', number); // Print the message and other information. +// count: 5 +console.info('count:'); // Print the message only. +// count: +``` ## console.warn -warn(message: string): void +warn(message: string, ...arguments: any[]): void -Prints warn-level logs. +Prints warning information in formatted output mode. **System capability**: SystemCapability.ArkUI.ArkUI.Full @@ -65,14 +96,25 @@ Prints warn-level logs. | Name | Type | Mandatory | Description | | ------- | ------ | ---- | ----------- | -| message | string | Yes | Text to print.| +| message | string | Yes | Warning information to be printed.| +| arguments | any | No | Arguments in the message or other information to be printed.| +**Example** +```js +const str = "name should be string"; +console.warn('warn: %d', str); // Print the warning information with arguments in the message replaced. +// warn: name should be string +console.warn('warn:', str); // Print the message and other information. +// warn: name should be string +console.warn('warn:'); // Print the message only. +// warn: +``` ## console.error -error(message: string): void +error(message: string, ...arguments: any[]): void -Prints error-level logs. +Prints error information in formatted output mode. **System capability**: SystemCapability.ArkUI.ArkUI.Full @@ -80,31 +122,26 @@ Prints error-level logs. | Name | Type | Mandatory | Description | | ------- | ------ | ---- | ----------- | -| message | string | Yes | Text to print.| +| message | string | Yes | Error information to be printed.| +| arguments | any | No | Arguments in the message or other information to be printed.| **Example** - +```js +const str = "value is not defined"; +console.error('error: %d', str); // Print the error information with arguments in the message replaced. +// error: value is not defined +console.error('error:', str); // Print the message and other information. +// error: value is not defined +console.error('error:'); // Print the message only. +// error: ``` -export default { - clickConsole(){ - var versionCode = 1; - console.info('Hello World. The current version code is ' + versionCode); - console.log(`versionCode: ${versionCode}`); - / / The following is supported since API version 6: console.log('versionCode:%d.', versionCode); - } -} -``` - -Switch to the HiLog window at the bottom of HUAWEI DevEco Studio. Specifically, select the current device and process, set the log level to Info, and enter Hello World in the search box. Logs that meet the search criteria are displayed, as shown in the following figure. - -![Printing logs](figures/printing-logs.png) ## console.assert10+ assert(value?: Object, ...arguments: Object[]): void -If **value** is false, the subsequent content will be printed. +Prints assertion information. **System capability**: SystemCapability.Utils.Lang @@ -112,24 +149,26 @@ If **value** is false, the subsequent content will be printed. | Name | Type | Mandatory | Description | | ------- | ------ | ---- | ----------- | -| value | Object | No | Value| -| arguments | Object | No | Prints error messages.| +| value | Object | No | Result value. If **value** is **false** or left blank, the output starting with "Assertion failed" is printed. If **value** is **true**, no information is printed.| +| arguments | Object | No | Other information to be printed when **value** is **false**. If this parameter is left blank, other information is not printed.| **Example** -``` -console.assert(true, 'does nothing'); +```js +console.assert(true, 'does nothing'); // Do not print error information as value is true. +console.assert(2% 1 == 0,'does nothing'); // Do not print error information as value is true. console.assert(false, 'console %s work', 'didn\'t'); -// Assertion console:ohos didn't work +// Assertion failed: console didn't work console.assert(); // Assertion failed ``` + ## console.count10+ count(label?: string): void -Adds a counter by the specified label name to count the number of times **console.count()** is called. The default value is **default**. +Maintains an internal counter. When this counter is invoked, its label name and the corresponding call count are printed. **System capability**: SystemCapability.Utils.Lang @@ -137,10 +176,11 @@ Adds a counter by the specified label name to count the number of times **consol | Name | Type | Mandatory | Description | | ------- | ------ | ---- | ----------- | -| label | string | No | Counter label name.| +| label | string | No | Counter label name. The default value is **default**.| + **Example** -``` +```js console.count() // default: 1 console.count('default') @@ -150,7 +190,7 @@ console.count('abc') console.count('xyz') // xyz: 1 console.count('abc') -abc: 2 +// abc: 2 console.count() // default: 3 ``` @@ -159,7 +199,7 @@ console.count() countReset(label?: string): void -Resets a counter by the specified label name. The default value is **default**. +Resets a counter based on the specified label name. **System capability**: SystemCapability.Utils.Lang @@ -167,10 +207,10 @@ Resets a counter by the specified label name. The default value is **default**. | Name | Type | Mandatory | Description | | ------- | ------ | ---- | ----------- | -| label | string | No | Counter label name.| +| label | string | No | Counter label name. The default value is **default**.| **Example** -``` +```js console.count('abc'); // abc: 1 console.countReset('abc'); @@ -190,13 +230,24 @@ Prints content of the specified object. | Name | Type | Mandatory | Description | | ------- | ------ | ---- | ----------- | -| dir | Object | No | Object whose content needs to be printed.| +| dir | Object | No | Object whose content needs to be printed. If this parameter is left blank, no information is printed.| + + +**Example** +```js +let a = { foo: { bar: { baz: true } }}; +console.dir(a); +// Object: {"foo":{"bar":{"baz":true}}} + +console.dir(); // No information is printed. +``` + ## console.dirxml10+ dirxml(...arguments: Object[]): void -Calls **console.log()** and passes the received parameters to it. This API does not produce any content of the XML format. +Displays an interactive tree of the descendant elements of the specified XML element. This API is implemented by calling **console.log()** internally. It does not produce any XML elements. The usage method is the same as that of **console.log()**. **System capability**: SystemCapability.Utils.Lang @@ -204,13 +255,24 @@ Calls **console.log()** and passes the received parameters to it. This API does | Name | Type | Mandatory | Description | | ------- | ------ | ---- | ----------- | -| arguments | Object | No | Information to be printed.| +| arguments | Object | Yes | Information to be printed.| + +**Example** +```js +const number = 5; +console.dirxml('count: %d', number); +// count: 5 +console.dirxml('count:', number); +// count: 5 +console.dirxml('count:'); +// count: +``` ## console.group10+ group(...arguments: Object[]): void -Creates an inline group so that subsequent lines are indented by the value specified by **groupIndentation**. +Increases the indentation of subsequent lines by two spaces. If the information to be printed is provided, the information is printed without extra indentation. **System capability**: SystemCapability.Utils.Lang @@ -220,11 +282,26 @@ If the information to be printed is provided, the information is printed without | Name | Type | Mandatory | Description | | ------- | ------ | ---- | ----------- | | arguments | Object | No | Information to be printed.| + +**Example** +```js +console.log("outter"); +// outter +console.group(); +console.log("level 1"); +// level 1 +console.group("in level1"); +// in level1 +console.log("level 2"); +// level 2 +``` + + ## console.groupCollapsed10+ groupCollapsed(...arguments: Object[]): void -Creates a collapsed inline group. +Creates a new inline group in collapsed mode. The usage and function of this API are the same as those of **console.group()**. **System capability**: SystemCapability.Utils.Lang @@ -234,14 +311,42 @@ Creates a collapsed inline group. | ------- | ------ | ---- | ----------- | | arguments | Object | No | Information to be printed.| + +**Example** +```js +console.groupCollapsed("outter"); +// outter +console.groupCollapsed(); +console.log("level 1"); +// level 1 +console.groupCollapsed("in level1"); +// in level1 +console.log("level 2"); +// level 2 +``` + ## console.groupEnd10+ groupEnd(): void -Exits an inline group so that subsequent lines are not indented by the value specified by **groupIndentation** . +Reduces the indentation of subsequent lines by two spaces. **System capability**: SystemCapability.Utils.Lang + +**Example** +```js +console.log("outter"); +// outter +console.group(); +console.log("level 1"); +// level 1 +console.groupEnd(); +console.log("outter"); +// outter +``` + + ## console.table10+ table(tableData?: Object): void @@ -254,10 +359,10 @@ Prints data in a table. | Name | Type | Mandatory | Description | | ------- | ------ | ---- | ----------- | -| tableData | Object | No | Data to be printed in a table.| +| tableData | Object | No | Data to be printed in a table. If this parameter is left blank, no information is printed.| **Example** -``` +```js console.table([1, 2, 3]); // ┌─────────┬────────┐ // │ (index) │ Values │ @@ -281,7 +386,7 @@ console.table({ a: [1, 2, 3, 4, 5], b: 5, c: { e: 5 } }); time(label?: string): void -Starts a timer to track the duration of an operation. The default value is **default**. You can use **console.timeEnd()** to disable the timer and print the result. +Starts a timer to track the duration of an operation. You can use **console.timeEnd()** to close the timer and print the elapsed time (in ms). **System capability**: SystemCapability.Utils.Lang @@ -289,13 +394,18 @@ Starts a timer to track the duration of an operation. The default value is **def | Name | Type | Mandatory | Description | | ------- | ------ | ---- | ----------- | -| label | string | No | Timer label.| +| label | string | No | Timer label. The default value is **default**.| + +**Example** +```js +console.time('abc'); +``` ## console.timeEnd10+ timeEnd(label?: string): void -Stops the timer started by **console.time()** and prints the result. The default value is **default**. +Stops the timer started by calling **console.time()** and prints the elapsed time (in ms). **System capability**: SystemCapability.Utils.Lang @@ -303,10 +413,10 @@ Stops the timer started by **console.time()** and prints the result. The default | Name | Type | Mandatory | Description | | ------- | ------ | ---- | ----------- | -| label | string | No | Timer label.| +| label | string | No | Timer label. The default value is **default**.| **Example** -``` +```js console.time('abc'); console.timeEnd('abc'); // abc: 225.438ms @@ -316,7 +426,7 @@ console.timeEnd('abc'); timeLog(label?: string, ...arguments: Object[]): void -Prints the elapsed time and other logs for the timer started by **console.time()**. +Prints the elapsed time and other data parameters for the timer started by **console.time()**. **System capability**: SystemCapability.Utils.Lang @@ -324,14 +434,13 @@ Prints the elapsed time and other logs for the timer started by **console.time() | Name | Type | Mandatory | Description | | ------- | ------ | ---- | ----------- | -| label | string | No | Timer label.| +| label | string | No | Timer label. The default value is **default**.| | arguments | Object | No | Logs to be printed.| **Example** -``` +```js console.time('timer1'); -const value = aaa (); // Return 17. -console.timeLog('timer1', value); +console.timeLog('timer1', 17); // timer1: 365.227ms 17 console.timeEnd('timer1'); // timer1: 513.22ms @@ -349,10 +458,14 @@ Creates a stack trace. | Name | Type | Mandatory | Description | | ------- | ------ | ---- | ----------- | -| arguments | Object | No | Logs to be printed.| +| arguments | Object | No | Logs to be printed. If this parameter is left blank, only stack information is printed.| **Example** -``` +```js console.trace(); +// Trace: +// xxxxxxxxxx (current stack information) console.trace("Show the trace"); +// Trace: Show the trace +// xxxxxxxxxx (current stack information) ``` diff --git a/en/application-dev/reference/apis/js-apis-net-policy.md b/en/application-dev/reference/apis/js-apis-net-policy.md deleted file mode 100644 index cb5f1624f6..0000000000 --- a/en/application-dev/reference/apis/js-apis-net-policy.md +++ /dev/null @@ -1,1555 +0,0 @@ -# @ohos.net.policy (Network Policy Management) - -The **policy** module provides APIs for managing network policies, through which you can control and manage the data volume used. - -> **NOTE** -> -> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. - -## Modules to Import - -```js -import policy from '@ohos.net.policy' -``` - -## policy.setBackgroundAllowed - -setBackgroundAllowed(isAllowed: boolean, callback: AsyncCallback\): void - -Sets a background network policy. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| isAllowed | boolean | Yes | Whether applications running in the background are allowed to use mobile data.| -| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation is successful, the operation result is returned. If the operation fails, an error message is returned.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -policy.setBackgroundAllowed(Boolean(Number.parseInt(this.isBoolean)), (error) => { - console.log(JSON.stringify(error)) -}) -; -``` - -## policy.setBackgroundAllowed - -setBackgroundAllowed(isAllowed: boolean): Promise\ - -Sets a background network policy. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| isAllowed | boolean | Yes | Whether applications running in the background are allowed to use mobile data.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\ | Promise used to return the result. If the operation is successful, the operation result is returned. If the operation fails, an error message is returned.| - -**Example** - -```js -policy.setBackgroundAllowed(Boolean(Number.parseInt(this.isBoolean))).then(function (error) { - console.log(JSON.stringify(error)) -}) -``` - -## policy.isBackgroundAllowed - -isBackgroundAllowed(callback: AsyncCallback\): void - -Obtains the background network policy. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation is successful, **true** is returned, which means that applications running in the background are allowed to use mobile data. If the operation fails, an error message is returned.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -policy.isBackgroundAllowed((error, data) => { - this.callBack(error, data); - console.log(JSON.stringify(error)) - console.log(JSON.stringify(data)) -}); -``` - -## policy.isBackgroundAllowed - -isBackgroundAllowed(): Promise\; - -Obtains the background network policy. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\ | Promise used to return the result. If the operation is successful, **true** is returned, which means that applications running in the background are allowed to use mobile data. If the operation fails, an error message is returned.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -policy.isBackgroundAllowed().then(function (error, data) { - console.log(JSON.stringify(error)) - console.log(JSON.stringify(data)) -}) -``` - -## policy.setPolicyByUid - -setPolicyByUid(uid: number, policy: NetUidPolicy, callback: AsyncCallback\): void - -Sets an application-specific network policy. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| uid | number | Yes | Unique ID of the application.| -| policy | [NetUidPolicy](#netuidpolicy) | Yes| Application-specific network policy to set.| -| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation is successful, the operation result is returned. If the operation fails, an error message is returned.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -let param = { - uid: Number.parseInt(this.firstParam), policy: Number.parseInt(this.currentNetUidPolicy) -} -policy.setPolicyByUid(Number.parseInt(this.firstParam), Number.parseInt(this.currentNetUidPolicy), (error) => { - this.callBack(error); -}); -``` - -## policy.setPolicyByUid - -setPolicyByUid(uid: number, policy: NetUidPolicy): Promise\; - -Sets an application-specific network policy. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| uid | number | Yes | Unique ID of the application.| -| policy | [NetUidPolicy](#netuidpolicy) | Yes| Application-specific network policy to set.| - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\ | Promise used to return the result. If the operation is successful, the operation result is returned. If the operation fails, an error message is returned.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -let param = { - uid: Number.parseInt(this.firstParam), policy: Number.parseInt(this.currentNetUidPolicy) -} -policy.setPolicyByUid(Number.parseInt(this.firstParam), Number.parseInt(this.currentNetUidPolicy)).then(function (error) { - console.log(JSON.stringify(error)) -}) -``` - -## policy.getPolicyByUid - -getPolicyByUid(uid: number, callback: AsyncCallback\): void - -Obtains an application-specific network policy by **uid**. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| uid | number | Yes| Unique ID of the application.| -| callback | AsyncCallback\<[NetUidPolicy](#netuidpolicy)> | Yes | Callback used to return the result. If the operation is successful, the operation result is returned. If the operation fails, an error message is returned.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -policy.getPolicyByUid(Number.parseInt(this.firstParam), (error, data) => { - this.callBack(error, data); -}); -``` - -## policy.getPolicyByUid - -getPolicyByUid(uid: number): Promise\; - -Obtains an application-specific network policy by **uid**. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| uid | number | Yes| Unique ID of the application.| - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\<[NetUidPolicy](#netuidpolicy)> | Promise used to return the result. If the operation is successful, the operation result is returned. If the operation fails, an error message is returned.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -policy.getPolicyByUid(Number.parseInt(this.firstParam)).then(function (error, data) { - console.log(JSON.stringify(error)) - console.log(JSON.stringify(data)) -}) -``` - -## policy.getUidsByPolicy - -getUidsByPolicy(policy: NetUidPolicy, callback: AsyncCallback\>): void - -Obtains the UID array of applications configured with a certain application-specific network policy. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| policy | [NetUidPolicy](#netuidpolicy) | Yes| Target application-specific network policy.| -| callback | AsyncCallback\> | Yes | Callback used to return the result. If the operation is successful, the operation result is returned. If the operation fails, an error message is returned.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -policy.getUidsByPolicy(Number.parseInt(this.currentNetUidPolicy), (error, data) => { - this.callBack(error, data); -}); -``` - -## policy.getUidsByPolicy - -function getUidsByPolicy(policy: NetUidPolicy): Promise\>; - -Obtains the UID array of applications configured with a certain application-specific network policy. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| policy | [NetUidPolicy](#netuidpolicy) | Yes| Target application-specific network policy.| - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\> | Promise used to return the result. If the operation is successful, the operation result is returned. If the operation fails, an error message is returned.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -policy.getUidsByPolicy(Number.parseInt(this.firstParam)).then(function (error, data) { - console.log(JSON.stringify(error)) - console.log(JSON.stringify(data)) -}) -``` - -## policy.getNetQuotaPolicies - -getNetQuotaPolicies(callback: AsyncCallback\>): void - -Obtains the network quota policies. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| callback | AsyncCallback\> | Yes | Callback used to return the result.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -policy.getNetQuotaPolicies((error, data) => { - this.callBack(error, data); -}); -``` - -## policy.getNetQuotaPolicies - -getNetQuotaPolicies(): Promise\>; - -Obtains the network quota policies. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\> | Promise used to return the result.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -policy.getNetQuotaPolicies().then(function (error, data) { - console.log(JSON.stringify(error)) - console.log(JSON.stringify(data)) -}) - -``` - -## policy.setNetQuotaPolicies - -setNetQuotaPolicies(quotaPolicies: Array\, callback: AsyncCallback\): void - -Sets an array of network quota policies. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| quotaPolicies | Array\<[NetQuotaPolicy](#netquotapolicy)> | Yes| An array of network quota policies to set.| -| callback | AsyncCallback\ | Yes | Callback used to return the result.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -let param = { - netType: Number.parseInt(this.netType), - iccid: this.iccid, - ident: this.ident, - periodDuration: this.periodDuration, - warningBytes: Number.parseInt(this.warningBytes), - limitBytes: Number.parseInt(this.limitBytes), - lastWarningRemind: this.lastWarningRemind, - lastLimitRemind: this.lastLimitRemind, - metered: Boolean(Number.parseInt(this.metered)), - limitAction: this.limitAction -}; -this.netQuotaPolicyList.push(param); - -policy.setNetQuotaPolicies(this.netQuotaPolicyList, (error) => { - console.log(JSON.stringify(error)) -}); -``` - -## policy.setNetQuotaPolicies - -setNetQuotaPolicies(quotaPolicies: Array\): Promise\; - -Sets an array of network quota policies. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| quotaPolicies | Array\<[NetQuotaPolicy](#netquotapolicy)> | Yes| An array of network quota policies to set.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\ | Promise used to return the result.| - -**Example** - -```js -let param = { - netType: Number.parseInt(this.netType), - iccid: this.iccid, - ident: this.ident, - periodDuration: this.periodDuration, - warningBytes: Number.parseInt(this.warningBytes), - limitBytes: Number.parseInt(this.limitBytes), - lastWarningRemind: this.lastWarningRemind, - lastLimitRemind: this.lastLimitRemind, - metered: Boolean(Number.parseInt(this.metered)), - limitAction: this.limitAction -}; -this.netQuotaPolicyList.push(param); - -policy.setNetQuotaPolicies(this.netQuotaPolicyList).then(function (error) { - console.log(JSON.stringify(error)) -}) -``` - -## policy.restoreAllPolicies - -restoreAllPolicies(iccid: string, callback: AsyncCallback\): void - -Restores all the policies (cellular network, background network, firewall, and application-specific network policies) for the given SIM card. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| iccid | string | Yes| SIM card ID.| -| callback | AsyncCallback\ | Yes | Callback used to return the result.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -this.firstParam = iccid; -policy.restoreAllPolicies(this.firstParam, (error) => { - console.log(JSON.stringify(error)) -}); -``` - -## policy.restoreAllPolicies - -restoreAllPolicies(iccid: string): Promise\; - -Restores all the policies (cellular network, background network, firewall, and application-specific network policies) for the given SIM card. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| iccid | string | Yes| SIM card ID.| - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\ | Promise used to return the result.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -this.firstParam = iccid; -policy.restoreAllPolicies(this.firstParam).then(function (error) { - console.log(JSON.stringify(error)) -}) -``` - -## policy.isUidNetAllowed - -isUidNetAllowed(uid: number, isMetered: boolean, callback: AsyncCallback\): void - -Checks whether an application is allowed to access metered networks. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| uid | number | Yes| Unique ID of the application.| -| isMetered | boolean | Yes| Whether the network is a metered network.| -| callback | AsyncCallback\ | Yes | Callback used to return the result. The value **true** means that the application is allowed to access metered networks, and **false** means the opposite.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -let param = { - uid: Number.parseInt(this.firstParam), isMetered: Boolean(Number.parseInt(this.isBoolean)) -} -policy.isUidNetAllowed(Number.parseInt(this.firstParam), Boolean(Number.parseInt(this.isBoolean)), (error, data) => { - this.callBack(error, data); -}); -``` - -## policy.isUidNetAllowed - -isUidNetAllowed(uid: number, isMetered: boolean): Promise\; - -Checks whether an application is allowed to access metered networks. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| uid | number | Yes| Unique ID of the application.| -| isMetered | boolean | Yes| Whether the network is a metered network.| - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\ | Promise used to return the result.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -let param = { - uid: Number.parseInt(this.firstParam), isMetered: Boolean(Number.parseInt(this.isBoolean)) -} -policy.isUidNetAllowed(Number.parseInt(this.firstParam), Boolean(Number.parseInt(this.isBoolean))).then(function (error, data) { - console.log(JSON.stringify(error)) - console.log(JSON.stringify(data)) -}) -``` - -## policy.isUidNetAllowed - -isUidNetAllowed(uid: number, iface: string, callback: AsyncCallback\): void - -Checks whether an application is allowed to access the given network. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| uid | number | Yes| Unique ID of the application.| -| iface | string | Yes| Name of the target network.| -| callback | AsyncCallback\ | Yes | Callback used to return the result. The value **true** means that the application is allowed to access the given network, and **false** means the opposite.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -let param = { - uid: Number.parseInt(this.firstParam), iface: this.secondParam -} -policy.isUidNetAllowed(Number.parseInt(this.firstParam), this.secondParam, (error, data) => { - this.callBack(error, data); -}); -``` - -## policy.isUidNetAllowed - -isUidNetAllowed(uid: number, iface: string): Promise\; - -Checks whether an application is allowed to access the given network. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| uid | number | Yes| Unique ID of the application.| -| iface | string | Yes| Name of the target network.| - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\ | Promise used to return the result.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -let param = { - uid: Number.parseInt(this.firstParam), iface: this.secondParam -} -policy.isUidNetAllowed(Number.parseInt(this.firstParam), this.secondParam).then(function (error, data) { - console.log(JSON.stringify(error)) - console.log(JSON.stringify(data)) -}) -``` - -## policy.setDeviceIdleAllowList - -setDeviceIdleAllowList(uid: number, isAllowed: boolean, callback: AsyncCallback\): void - -Sets whether to add an application to the device idle allowlist. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| uid | number | Yes| Unique ID of the application.| -| isAllowed | boolean | Yes| Whether to add the application to the allowlist.| -| callback | callback: AsyncCallback\ | Yes | Callback used to return the result.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -let param = { - uid: Number.parseInt(this.firstParam), isAllowed: Boolean(Number.parseInt(this.isBoolean)) -} -policy.setDeviceIdleAllowList(Number.parseInt(this.firstParam), Boolean(Number.parseInt(this.isBoolean)), (error) => { - console.log(JSON.stringify(error)) -}); -``` - -## policy.setDeviceIdleAllowList - -setDeviceIdleAllowList(uid: number, isAllowed: boolean): Promise\; - -Sets whether to add an application to the device idle allowlist. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| uid | number | Yes| Unique ID of the application.| -| isAllowed | boolean | Yes| Whether to add the application to the allowlist.| - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\ | Promise used to return the result.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -let param = { - uid: Number.parseInt(this.firstParam), isAllowed: Boolean(Number.parseInt(this.isBoolean)) -} -policy.setDeviceIdleAllowList(Number.parseInt(this.firstParam), Boolean(Number.parseInt(this.isBoolean))).then(function (error) { - console.log(JSON.stringify(error)) -}) -``` - -## policy.getDeviceIdleAllowList - -getDeviceIdleAllowList(callback: AsyncCallback\>): void - -Obtains the UID array of applications that are on the device idle allowlist. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| callback | AsyncCallback\> | Yes | Callback used to return the result.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -policy.getDeviceIdleAllowList((error, data) => { - this.callBack(error, data); -}); -``` - -## policy.getDeviceIdleAllowList - -getDeviceIdleAllowList(): Promise\>; - -Obtains the UID array of applications that are on the device idle allowlist. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\> | Promise used to return the result.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -policy.getDeviceIdleAllowList().then(function (error, data) { - console.log(JSON.stringify(error)) - console.log(JSON.stringify(data)) -}) -``` - -## policy.getBackgroundPolicyByUid - -getBackgroundPolicyByUid(uid: number, callback: AsyncCallback\): void - -Obtains the background network policies configured for the given application. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| uid | number | Yes| Unique ID of the application.| -| callback | AsyncCallback\<[NetBackgroundPolicy](#netbackgroundpolicy)> | Yes | Callback used to return the result.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -this.firstParam = uid -policy.getBackgroundPolicyByUid(Number.parseInt(this.firstParam), (error, data) => { - this.callBack(error, data); -}); -``` - -## policy.getBackgroundPolicyByUid - -getBackgroundPolicyByUid(uid: number): Promise\; - -Obtains the background network policies configured for the given application. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| uid | number | Yes| Unique ID of the application.| - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\<[NetBackgroundPolicy](#netbackgroundpolicy)> | Promise used to return the result.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -this.firstParam = uid -policy.getBackgroundPolicyByUid(Number.parseInt(this.firstParam)).then(function (error, data) { - console.log(JSON.stringify(error)) - console.log(JSON.stringify(data)) -}) -``` - -## policy.resetPolicies - -resetPolicies(iccid: string, callback: AsyncCallback\): void - -Restores all the policies (cellular network, background network, firewall, and application-specific network policies) for the given SIM card. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| iccid | string | Yes| SIM card ID.| -| callback | AsyncCallback\ | Yes | Callback used to return the result.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -this.firstParam = iccid -policy.resetPolicies(this.firstParam, (error) => { - console.log(JSON.stringify(error)) -}); -``` - -## policy.resetPolicies - -resetPolicies(iccid: string): Promise\; - -Restores all the policies (cellular network, background network, firewall, and application-specific network policies) for the given SIM card. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| iccid | string | Yes| SIM card ID.| - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\ | Promise used to return the result.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -policy.getUidsByPolicy(Number.parseInt(this.firstParam)).then(function (error, data) { - -}) -this.firstParam = iccid -policy.resetPolicies(this.firstParam).then(function (error) { - console.log(JSON.stringify(error)) -}) -``` - -## policy.updateRemindPolicy - -updateRemindPolicy(netType: NetBearType, iccid: string, remindType: RemindType, callback: AsyncCallback\): void - -Updates a reminder policy. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| netType | [NetBearType](js-apis-net-connection.md#netbeartype) | Yes| Network type.| -| iccid | string | Yes| SIM card ID.| -| remindType | [RemindType](#remindtype) | Yes| Reminder type.| -| callback | AsyncCallback\ | Yes | Callback used to return the result.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -let param = { - netType: Number.parseInt(this.netType), iccid: this.firstParam, remindType: this.currentRemindType -} -policy.updateRemindPolicy(Number.parseInt(this.netType), this.firstParam, Number.parseInt(this.currentRemindType), (error) => { - console.log(JSON.stringify(error)) -}); -``` - -## policy.updateRemindPolicy - -updateRemindPolicy(netType: NetBearType, iccid: string, remindType: RemindType): Promise\; - -Updates a reminder policy. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| netType | [NetBearType](js-apis-net-connection.md#netbeartype) | Yes| Network type.| -| iccid | string | Yes| SIM card ID.| -| remindType | [RemindType](#remindtype) | Yes| Reminder type.| - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\ | Promise used to return the result.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -let param = { - netType: Number.parseInt(this.netType), iccid: this.firstParam, remindType: this.currentRemindType -} -policy.updateRemindPolicy(Number.parseInt(this.netType), this.firstParam, Number.parseInt(this.currentRemindType)).then(function (error) { - console.log(JSON.stringify(error)) -}) -``` - -## policy.setPowerSaveAllowList - -setPowerSaveAllowList(uid: number, isAllowed: boolean, callback: AsyncCallback\): void - -Sets whether to add an application to the power-saving allowlist. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| uid | number | Yes| Unique ID of the application.| -| isAllowed | boolean | Yes| Whether to add the application to the allowlist.| -| callback | callback: AsyncCallback\ | Yes | Callback used to return the result.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -let param = { - uid: Number.parseInt(this.firstParam), isAllowed: Boolean(Number.parseInt(this.isBoolean)) -} -policy.setPowerSaveAllowList(Number.parseInt(this.firstParam), Boolean(Number.parseInt(this.isBoolean)), (error) => { - console.log(JSON.stringify(error)) -}); -``` - -## policy.setPowerSaveAllowList - -setPowerSaveAllowList(uid: number, isAllowed: boolean): Promise\; - -Sets whether to add an application to the power-saving allowlist. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| uid | number | Yes| Unique ID of the application.| -| isAllowed | boolean | Yes| Whether to add the application to the allowlist.| - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\ | Promise used to return the result.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 401 | Parameter error. | -| 2100001 | Invalid parameter value. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -let param = { - uid: Number.parseInt(this.firstParam), isAllowed: Boolean(Number.parseInt(this.isBoolean)) -} -policy.setPowerSaveAllowList(Number.parseInt(this.firstParam), Boolean(Number.parseInt(this.isBoolean))).then(function (error) { - console.log(JSON.stringify(error)) -}) -``` - -## policy.getPowerSaveAllowList - -getPowerSaveAllowList(callback: AsyncCallback\>): void - -Obtains the UID array of applications that are on the power-saving allowlist. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| callback | AsyncCallback\> | Yes | Callback used to return the result.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -policy.getPowerSaveAllowList((error, data) => { - this.callBack(error, data); -}); -``` - -## policy.getPowerSaveAllowList - -getPowerSaveAllowList(): Promise\>; - -Obtains the UID array of applications that are on the device idle allowlist. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\> | Promise used to return the result.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**Example** - -```js -policy.getPowerSaveAllowList().then(function (error, data) { - console.log(JSON.stringify(error)) - console.log(JSON.stringify(data)) -}) -``` - -## policy.on - -Functions as the handle to a network policy. - -### on('netUidPolicyChange') - -on(type: "netUidPolicyChange", callback: Callback\<{ uid: number, policy: NetUidPolicy }>): void - -Subscribes to policy changes. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ---------------------------------- | ---- | ------------------------------------------------------------ | -| type | netUidPolicyChange | Yes| Event type. The value **netUidPolicyChange** indicates a policy change event.| -| callback | Callback\<{ uid: number, policy: [NetUidPolicy](#netuidpolicy) }> | Yes | Callback used to return the result. It is called when the registered network policy changes.| - -**Example** - -```js -policy.on('netUidPolicyChange', (data) => { - this.log('on netUidPolicyChange: ' + JSON.stringify(data)); -}) -``` - -### on('netUidRuleChange') - -on(type: "netUidRuleChange", callback: Callback\<{ uid: number, rule: NetUidRule }>): void - -Subscribes to rule changes. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ---------------------------------- | ---- | ------------------------------------------------------------ | -| type | netUidRuleChange | Yes| Event type. The value **netUidRuleChange** indicates a rule change event.| -| callback | Callback\<{ uid: number, rule: [NetUidRule](#netuidrule) }> | Yes | Callback used to return the result. It is called when the registered rule changes.| - -**Example** - -```js -policy.on('netUidRuleChange', (data) => { - this.log('on netUidRuleChange: ' + JSON.stringify(data)); -}) -``` - -### on('netMeteredIfacesChange') - -on(type: "netMeteredIfacesChange", callback: Callback\>): void - -Subscribes to metered **iface** changes. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ---------------------------------- | ---- | ------------------------------------------------------------ | -| type | netMeteredIfacesChange | Yes| Event type. The value **netMeteredIfacesChange** indicates a metered **iface** change event.| -| callback | Callback\> | Yes | Callback used to return the result. It is called when the registered metered **iface** changes.| - -**Example** - -```js -policy.on('netMeteredIfacesChange', (data) => { - this.log('on netMeteredIfacesChange: ' + JSON.stringify(data)); -}) -``` - -### on('netQuotaPolicyChange') - -on(type: "netQuotaPolicyChange", callback: Callback\>): void - -Subscribes to network quota policy changes. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ---------------------------------- | ---- | ------------------------------------------------------------ | -| type | netQuotaPolicyChange | Yes| Event type. The value **netQuotaPolicyChange** indicates a network quota policy change event.| -| callback | Callback\> | Yes | Callback used to return the result. It is called when the registered network quota policy changes.| - -**Example** - -```js -policy.on('netQuotaPolicyChange', (data) => { - this.log('on netQuotaPolicyChange: ' + JSON.stringify(data)); -}) -``` - -### on('netBackgroundPolicyChange') - -on(type: "netBackgroundPolicyChange", callback: Callback\): void - -Subscribes to background network policy changes. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ---------------------------------- | ---- | ------------------------------------------------------------ | -| type | netBackgroundPolicyChange | Yes| Event type. The value **netBackgroundPolicyChange** indicates a background network policy change event.| -| callback | Callback\ | Yes | Callback used to return the result. It is called when the registered background network policy changes.| - -**Example** - -```js -policy.on('netBackgroundPolicyChange', (data) => { - this.log('on netBackgroundPolicyChange: ' + JSON.stringify(data)); -}) -``` - -## NetBackgroundPolicy - -Enumerates the background network policies. - -**System capability**: SystemCapability.Communication.NetManager.Core - -| Name | Value | Description | -| ------------------------ | ---- | ---------------------- | -| NET_BACKGROUND_POLICY_NONE | 0 | Default policy.| -| NET_BACKGROUND_POLICY_ENABLE | 1 | Applications running in the background are allowed to access metered networks.| -| NET_BACKGROUND_POLICY_DISABLE | 2 | Applications running in the background are not allowed to access metered networks.| -| NET_BACKGROUND_POLICY_ALLOW_LIST | 3 | Only applications on the allowlist are allowed to access metered networks when they are running in the background.| - -## NetQuotaPolicy - -Defines a network quota policy. - -**System capability**: SystemCapability.Communication.NetManager.Core - -| Name | Type | Description | -| ----------------------- | ----------------------------------- | ------------------------------------------------------------ | -| netType | [NetBearType](js-apis-net-connection.md#netbeartype) | Network type.| -| iccid | string | Identifier of the SIM card on the metered cellular network. It is not used for Wi-Fi networks.| -| ident | string | Identifier of the SIM card on the metered cellular network. It is used for Wi-Fi networks. It is used together with **iccid**.| -| periodDuration | string | Start time of metering.| -| warningBytes | number | Data volume threshold for generating an alarm.| -| limitBytes | number | Data volume quota.| -| lastWarningRemind | string | Last time when an alarm was generated.| -| lastLimitRemind | string | Last time when the quota was exhausted.| -| metered | string | Whether the network is a metered network.| -| limitAction | [LimitAction](#limitaction) | Action to take when the data volume quota is reached.| - -## LimitAction - -Enumerates the actions that can be taken when the data volume quota is reached. - -**System capability**: SystemCapability.Communication.NetManager.Core - -| Name | Value| Description | -| ---------------------- | ----- | ------------ | -| LIMIT_ACTION_NONE | -1 | Default policy.| -| LIMIT_ACTION_DISABLE | 0 | Internet access is disabled.| -| LIMIT_ACTION_AUTO_BILL| 1 | Users will be automatically charged for the data volume they use.| - -## NetUidRule - -Enumerates the metered network rules. - -**System capability**: SystemCapability.Communication.NetManager.Core - -| Name | Value| Description | -| ---------------------- | ----- | ------------ | -| NET_RULE_NONE | 0 | Default rule.| -| NET_RULE_ALLOW_METERED_FOREGROUND | 1 | Applications running in the foreground are allowed to access metered networks.| -| NET_RULE_ALLOW_METERED | 2 | Applications are allowed to access metered networks.| -| NET_RULE_REJECT_METERED | 4 | Applications are not allowed to access metered networks.| -| NET_RULE_ALLOW_ALL | 32 | Applications are allowed to access all networks (metered or non-metered).| -| NET_RULE_REJECT_ALL | 64 | Applications are not allowed to access any networks (metered or non-metered).| - -## RemindType - -Enumerates the reminder types. - -**System capability**: SystemCapability.Communication.NetManager.Core - -| Name| Value| Description| -| ---------------------- | - | ------- | -| REMIND_TYPE_WARNING | 1 | Warning.| -| REMIND_TYPE_LIMIT | 2 | Limit.| - -## NetUidPolicy - -Enumerates the application-specific network policies. - -**System capability**: SystemCapability.Communication.NetManager.Core - -| Name | Value| Description | -| ---------------------- | ----- | ------------ | -| NET_POLICY_NONE | 0 | Default network policy.| -| NET_POLICY_ALLOW_METERED_BACKGROUND | 1 | Applications running in the background are allowed to access metered networks.| -| NET_POLICY_REJECT_METERED_BACKGROUND | 2 | Applications running in the background are not allowed to access metered networks.| diff --git a/en/application-dev/reference/apis/js-apis-rpc.md b/en/application-dev/reference/apis/js-apis-rpc.md index c4688c804e..e444fd018a 100644 --- a/en/application-dev/reference/apis/js-apis-rpc.md +++ b/en/application-dev/reference/apis/js-apis-rpc.md @@ -45,9 +45,9 @@ During RPC or IPC, the sender can use the **write()** method provided by **Messa ### create - static create(): MessageSequence +static create(): MessageSequence - Creates a **MessageSequence** object. This API is a static method. +Creates a **MessageSequence** object. This API is a static method. **System capability**: SystemCapability.Communication.IPC.Core @@ -6821,8 +6821,8 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode } let deathRecipient = new MyDeathRecipient(); try { - proxy.registerDeathRecippient(deathRecipient, 0); - proxy.unregisterDeathRecippient(deathRecipient, 0); + proxy.registerDeathRecipient(deathRecipient, 0); + proxy.unregisterDeathRecipient(deathRecipient, 0); } catch(error) { console.info("proxy register deathRecipient fail, errorCode " + error.code); console.info("proxy register deathRecipient fail, errorMessage " + error.message); @@ -6893,7 +6893,7 @@ Removes the callback used to receive death notifications of the remote object. } } let deathRecipient = new MyDeathRecipient(); - proxy.addDeathRecippient(deathRecipient, 0); + proxy.addDeathRecipient(deathRecipient, 0); proxy.removeDeathRecipient(deathRecipient, 0); ``` diff --git a/en/application-dev/reference/apis/js-apis-shortKey.md b/en/application-dev/reference/apis/js-apis-shortKey.md new file mode 100644 index 0000000000..79a8ce2664 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-shortKey.md @@ -0,0 +1,81 @@ +# @ohos.multimodalInput.shortKey (Shortcut Key) + +The **shortKey** module provides APIs to set the delay for starting an ability using a shortcut key. For example, you can set the delay to 3 seconds so that a screenshot is taken when you press and hold the shortcut key for 3 seconds. + +> **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. +> - The APIs provided by this module are system APIs. + +## Modules to Import + +``` +import shortKey from '@ohos.multimodalInput.shortKey'; +``` + +## shortKey.setKeyDownDuration + +setKeyDownDuration(businessId: string, delay: number, callback: AsyncCallback<void>): void + +Sets the delay for starting an ability using the shortcut key. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.MultimodalInput.Input.ShortKey + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ------------------- | ---- | ------------------------------------------------------------ | +| businessId | string | Yes | Unique service ID registered on the multimodal side. It corresponds to **businessId** in the **ability_launch_config.json** file.| +| delay | number | Yes | Delay for starting an ability using the shortcut key, in ms.| +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | + +**Example** + +``` +try { + shortKey.setKeyDownDuration("screenshot", 500, (error) => { + if (error) { + console.log(`Set key down duration failed, error: ${JSON.stringify(error, [`code`, `message`])}`); + return; + } + console.log(`Set key down duration success`); + }); +} catch (error) { + console.log(`Set key down duration failed, error: ${JSON.stringify(error, [`code`, `message`])}`); +} +``` + + + +## shortKey.setKeyDownDuration + +setKeyDownDuration(businessId: string, delay: number): Promise<void> + +Sets the delay for starting an ability using the shortcut key. This API uses a promise to return the result. + +**System capability**: SystemCapability.MultimodalInput.Input.ShortKey + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ------ | ---- | ------------------------------------------------------------ | +| businessId | string | Yes | Unique service ID registered on the multimodal side. It corresponds to **businessId** in the **ability_launch_config.json** file.| +| delay | number | Yes | Delay for starting an ability using the shortcut key, in ms.| + +**Return value** + +| Parameters | Description | +| ------------- | ------------- | +| Promise<void> | Promise used to return the result.| + +**Example** + +``` +try { + shortKey.setKeyDownDuration("screenshot", 500).then(() => { + console.log(`Set key down duration success`); + }); +} catch (error) { + console.log(`Set key down duration failed, error: ${JSON.stringify(error, [`code`, `message`])}`); +} +``` diff --git a/en/application-dev/reference/apis/js-apis-system-battery.md b/en/application-dev/reference/apis/js-apis-system-battery.md index efeb9caec5..8eef0562cd 100644 --- a/en/application-dev/reference/apis/js-apis-system-battery.md +++ b/en/application-dev/reference/apis/js-apis-system-battery.md @@ -27,7 +27,7 @@ Obtains the current charging state and battery level. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| options | [GetStatusOptions](#getstatusoptions) | No| Object that contains the API calling result.| +| options | [GetStatusOptions](#getstatusoptions) | No| Object that contains the API calling result. This parameter is optional and is left blank by default.| **Example** @@ -50,9 +50,9 @@ Object that contains the API calling result. | Name | Type | Mandatory| Description | | -------- | --------------------------------------------------- | ---- | ------------------------------------------------------------ | -| success | (data: [BatteryResponse](#batteryresponse)) => void | No | Called when API call is successful. **data** is a return value of the [BatteryResponse](#batteryresponse) type.| -| fail | (data: string, code: number) => void | No | Called when API call has failed. **data** indicates the error information, and **code** indicates the error code. | -| complete | () => void | No | Called when API call is complete. | +| success | (data: [BatteryResponse](#batteryresponse)) => void | No | Called when an API call is successful. **data** is a return value of the [BatteryResponse](#batteryresponse) type.| +| fail | (data: string, code: number) => void | No | Called when an API call has failed. **data** indicates the error information, and **code** indicates the error code. | +| complete | () => void | No | Called when an API call is complete. | ## BatteryResponse 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 8053c8f0c7..01a1defec2 100644 --- a/en/application-dev/reference/apis/js-apis-system-brightness.md +++ b/en/application-dev/reference/apis/js-apis-system-brightness.md @@ -28,7 +28,7 @@ Obtains the current screen brightness. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| options | [GetBrightnessOptions](#getbrightnessoptions) | No | Options for obtaining the screen brightness.| +| options | [GetBrightnessOptions](#getbrightnessoptions) | No | Options for obtaining the screen brightness. This parameter is optional and is left blank by default.| **Example** @@ -56,7 +56,7 @@ Sets the screen brightness. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| options | [SetBrightnessOptions](#setbrightnessoptions) | No | Options for setting the screen brightness.| +| options | [SetBrightnessOptions](#setbrightnessoptions) | No | Options for setting the screen brightness. This parameter is optional and is left blank by default.| **Example** @@ -85,7 +85,7 @@ Obtains the screen brightness adjustment mode. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| options | [GetBrightnessModeOptions](#getbrightnessmodeoptions) | No| Options for obtaining the screen brightness mode.| +| options | [GetBrightnessModeOptions](#getbrightnessmodeoptions) | No| Options for obtaining the screen brightness mode. This parameter is optional and is left blank by default.| **Example** @@ -112,7 +112,7 @@ Sets the screen brightness adjustment mode. **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| options | [SetBrightnessModeOptions](#setbrightnessmodeoptions) | No | Options for setting the screen brightness mode.| +| options | [SetBrightnessModeOptions](#setbrightnessmodeoptions) | No | Options for setting the screen brightness mode. This parameter is optional and is left blank by default.| **Example** @@ -143,7 +143,7 @@ Sets whether to always keep the screen on. Call this API in **onShow()**. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| options | [SetKeepScreenOnOptions](#setkeepscreenonoptions) | No| Options for setting the screen to be steady on.| +| options | [SetKeepScreenOnOptions](#setkeepscreenonoptions) | No| Options for setting the screen to be steady on. This parameter is optional and is left blank by default.| **Example** @@ -166,9 +166,9 @@ Defines the options for obtaining the screen brightness. | Name | Type | Mandatory| Description | | -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | -| success | (data: [BrightnessResponse](#brightnessresponse)) => void | No | Called when API call is successful. **data** is a return value of the [BrightnessResponse](#brightnessresponse) type.| -| fail | (data: string, code: number) => void | No | Called when API call has failed. **data** indicates the error information, and **code** indicates the error code. | -| complete | () => void | No | Called when the API call is complete. | +| success | (data: [BrightnessResponse](#brightnessresponse)) => void | No | Called when an API call is successful. **data** is a return value of the [BrightnessResponse](#brightnessresponse) type.| +| fail | (data: string, code: number) => void | No | Called when an API call has failed. **data** indicates the error information, and **code** indicates the error code. | +| complete | () => void | No | Called when an API call is complete. | ## SetBrightnessOptions @@ -178,10 +178,10 @@ Defines the options for setting the screen brightness. | Name | Type | Mandatory| Description | | -------- | ------------------------------------ | ---- | ------------------------------------------------------------ | -| value | number | Yes | Screen brightness. The value is an integer ranging from **1** to **255**.
- If the value is less than or equal to **0**, value **1** will be used.
- If the value is greater than **255**, value **255** will be used.
- If the value contains decimals, the integral part of the value will be used. For example, if value **8.1** is set, value **8** will be used.| -| success | () => void | No | Callback upon a successful API call. | -| fail | (data: string, code: number) => void | No | Called when API call has failed. **data** indicates the error information, and **code** indicates the error code. | -| complete | () => void | No | Called when the API call is complete. | +| value | number | Yes | Screen brightness. The value is an integer ranging from **1** to **255**.
- If the value is less than or equal to **0**, value **1** will be used.
- If the value is greater than **255**, value **255** will be used.
- If the value contains decimals, the integral part of the value will be used. For example, if value **8.1** is set, value **8** will be used.| +| success | () => void | No | Called when an API call is successful. | +| fail | (data: string, code: number) => void | No | Called when an API call has failed. **data** indicates the error information, and **code** indicates the error code. | +| complete | () => void | No | Called when an API call is complete. | ## BrightnessResponse @@ -201,9 +201,9 @@ Defines the options for obtaining the screen brightness mode. | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| success | (data: [BrightnessModeResponse](#brightnessmoderesponse)) => void | No | Called when API call is successful. **data** is a return value of the [BrightnessModeResponse](#brightnessmoderesponse) type.| -| fail | (data: string, code: number) => void | No | Called when API call has failed. **data** indicates the error information, and **code** indicates the error code. | -| complete | () => void | No | Called when the API call is complete. | +| success | (data: [BrightnessModeResponse](#brightnessmoderesponse)) => void | No | Called when an API call is successful. **data** is a return value of the [BrightnessModeResponse](#brightnessmoderesponse) type.| +| fail | (data: string, code: number) => void | No | Called when an API call has failed. **data** indicates the error information, and **code** indicates the error code. | +| complete | () => void | No | Called when an API call is complete. | ## SetBrightnessModeOptions @@ -214,9 +214,9 @@ Defines the options for setting the screen brightness mode. | Name | Type | Mandatory| Description | | -------- | ------------------------------------ | ---- | ------------------------------------------------------ | | mode | number | Yes | The value **0** indicates the manual adjustment mode, and the value **1** indicates the automatic adjustment mode.| -| success | () => void | No | Callback upon a successful API call. | -| fail | (data: string, code: number) => void | No | Called when API call has failed. **data** indicates the error information, and **code** indicates the error code.| -| complete | () => void | No | Called when the API call is complete. | +| success | () => void | No | Called when an API call is successful. | +| fail | (data: string, code: number) => void | No | Called when an API call has failed. **data** indicates the error information, and **code** indicates the error code.| +| complete | () => void | No | Called when an API call is complete. | ## BrightnessModeResponse @@ -237,6 +237,6 @@ Defines the options for setting the screen to be steady on. | Name | Type | Mandatory| Description | | ------------ | ------------------------------------ | ---- | ------------------------------------------------------ | | keepScreenOn | boolean | Yes | The value **true** means to keep the screen steady on, and the value **false** indicates the opposite. | -| success | () => void | No | Callback upon a successful API call. | -| fail | (data: string, code: number) => void | No | Called when API call has failed. **data** indicates the error information, and **code** indicates the error code.| -| complete | () => void | No | Called when the API call is complete. | +| success | () => void | No | Called when an API call is successful. | +| fail | (data: string, code: number) => void | No | Called when an API call has failed. **data** indicates the error information, and **code** indicates the error code.| +| complete | () => void | No | Called when an API call is complete. | diff --git a/en/application-dev/reference/apis/js-apis-thermal.md b/en/application-dev/reference/apis/js-apis-thermal.md index d9914d9c86..add214749c 100644 --- a/en/application-dev/reference/apis/js-apis-thermal.md +++ b/en/application-dev/reference/apis/js-apis-thermal.md @@ -1,6 +1,6 @@ # @ohos.thermal (Thermal Management) -The **thermal** module provides thermal level-related callback and query APIs to obtain the information required for thermal control. +This module provides thermal level-related callback and query APIs to obtain the information required for thermal control. > **NOTE** > @@ -90,7 +90,7 @@ Obtains the current thermal level. **System capability:** SystemCapability.PowerManager.ThermalManager -**Return value** +**Return value**: | Type | Description | | ------------ | ------------ | @@ -173,7 +173,7 @@ Obtains the current thermal level. **System capability:** SystemCapability.PowerManager.ThermalManager -**Return value** +**Return value**: | Type | Description | | ------------ | ------ | diff --git a/en/application-dev/reference/errorcodes/Readme-EN.md b/en/application-dev/reference/errorcodes/Readme-EN.md index a9e53ed27e..dd7b0dc1e4 100644 --- a/en/application-dev/reference/errorcodes/Readme-EN.md +++ b/en/application-dev/reference/errorcodes/Readme-EN.md @@ -55,7 +55,6 @@ - [Network Connection Management Error Codes](errorcode-net-connection.md) - [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) diff --git a/en/application-dev/reference/errorcodes/errorcode-i18n.md b/en/application-dev/reference/errorcodes/errorcode-i18n.md index e78abf39b8..6b269c1744 100644 --- a/en/application-dev/reference/errorcodes/errorcode-i18n.md +++ b/en/application-dev/reference/errorcodes/errorcode-i18n.md @@ -26,7 +26,7 @@ Check whether the parameter type is correct. **Error Message** -Unspported option value. +param value not valid **Description** diff --git a/en/application-dev/reference/errorcodes/errorcode-loglibrary.md b/en/application-dev/reference/errorcodes/errorcode-loglibrary.md new file mode 100644 index 0000000000..8bfe5c1241 --- /dev/null +++ b/en/application-dev/reference/errorcodes/errorcode-loglibrary.md @@ -0,0 +1,24 @@ +# Log Library Error Codes + +> **NOTE** +> +> This topic describes only module-specific error codes. For details about universal error codes, see [Universal Error Codes](errorcode-universal.md). + +## 21300001 Specified File Not Exist + +**Error Message** + +The specified file does not exist. + +**Description** + +When the **copy**, **move**, or **delete** API is called to perform file operations, the file with the specified name does not exist in the specified type of logs. + +**Possible Cause** + +1. The input file name is incorrect. +2. The file with the input file name does not exist. + +**Procedure** + +Check whether the input file name is correct. diff --git a/en/application-dev/reference/errorcodes/errorcode-net-policy.md b/en/application-dev/reference/errorcodes/errorcode-net-policy.md deleted file mode 100644 index 594f498f72..0000000000 --- a/en/application-dev/reference/errorcodes/errorcode-net-policy.md +++ /dev/null @@ -1,63 +0,0 @@ -# Policy Management Error Codes - -> **NOTE** -> -> This topic describes only module-specific error codes. For details about universal error codes, see [Universal Error Codes](errorcode-universal.md). - -## 2100001 Invalid Parameter Value - -**Error Message** - -Invalid parameter value. - -**Description** - -Invalid parameter value - -**Cause** - -The input parameter value is not within the valid value range. - -**Procedure** - -Check whether the input parameter value is within the valid value range. - -## 2100002 Service Connection Failure - -**Error Message** - -Operation failed. Cannot connect to service. - -**Description** - -This error code is reported if a service connection failure occurs. - -**Cause** - -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. - -**Cause** - -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. diff --git a/en/device-dev/subsystems/subsys-power-mode-customization.md b/en/device-dev/subsystems/subsys-power-mode-customization.md index 093d13bf1d..8903184581 100644 --- a/en/device-dev/subsystems/subsys-power-mode-customization.md +++ b/en/device-dev/subsystems/subsys-power-mode-customization.md @@ -4,7 +4,7 @@ ### Introduction -By default, OpenHarmony provides the power mode feature, which offers the following options: normal mode, performance mode, power-saving mode, and ultra power-saving mode. However, the power mode configuration varies according to hardware specifications of different products. To address this issue, OpenHarmony provides the power mode customization function, allowing you to customize power modes depending on your hardware specifications. +By default, OpenHarmony provides the power mode feature, which offers the following options: normal mode, performance mode, power-saving mode, and super power-saving mode. However, the power mode configuration varies according to hardware specifications of different products. To address this issue, OpenHarmony provides the power mode customization function, allowing you to customize power modes depending on your hardware specifications. ### Basic Concepts @@ -16,7 +16,7 @@ OpenHarmony supports the following four power modes, each of which corresponds t - Power-saving mode: power mode that emphasizes on power saving, such as decreasing the system brightness, reducing the screen-off time, and shortening the time for entering sleep mode. -- Ultra power-saving mode: power mode that emphasizes on ultimate power saving, such as greatly decreasing the system brightness, greatly reducing the screen-off time, and greatly shortening the time for entering sleep mode. +- Super power-saving mode: power mode that emphasizes on ultimate power saving, such as greatly decreasing the system brightness, greatly reducing the screen-off time, and greatly shortening the time for entering sleep mode. ### Constraints @@ -59,7 +59,7 @@ The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/ma | Normal mode| 600 | | Power-saving mode| 601 | | Performance mode| 602 | - | Ultra power-saving mode| 603 | + | Super power-saving mode| 603 | The **switch** node is used to configure items of the power mode. @@ -243,9 +243,9 @@ The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/ma 4. Turn on the screen. If the screen turns off after 30 seconds, the setting of the auto sleep time is successful. -5. Set the power mode to the ultra power-saving mode, and verify the setting. +5. Set the power mode to the super power-saving mode, and verify the setting. - 1. Set the power mode to the ultra power-saving mode. + 1. Set the power mode to the super power-saving mode. ```shell power-shell setmode 603 @@ -278,8 +278,6 @@ The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/ma ## Reference -During development, you can refer to the [default power mode configuration](https://gitee.com/openharmony/powermgr_power_manager/tree/master/services/native/profile): - -[Default configuration](https://gitee.com/openharmony/powermgr_power_manager/blob/master/services/native/profile/power_mode_config.xml) +During development, you can refer to the [default power mode configuration](https://gitee.com/openharmony/powermgr_power_manager/blob/master/services/native/profile/power_mode_config.xml): Packing path: `/system/etc/power_config/power_mode_config.xml` diff --git a/en/device-dev/subsystems/subsys-thermal_control.md b/en/device-dev/subsystems/subsys-thermal_control.md index a97216aae2..5dbb6ab4e9 100644 --- a/en/device-dev/subsystems/subsys-thermal_control.md +++ b/en/device-dev/subsystems/subsys-thermal_control.md @@ -52,7 +52,7 @@ The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/ma | name="current" | Charging current control | event | - **1**: event sending enabled
-**0**: event sending disabled| int | 0 or 1| | name="voltage" | Charging voltage control (charging voltage during fast charging and slow charging)| protocol | Supported charging protocols: fast charging (supercharge) and slow charging (buck)| string | sc or buck| | name="voltage" | Charging voltage control | event | - **1**: event sending enabled
-**0**: event sending disabled| int | 0 or 1| - | name="process_ctrl" | Process control (survival status of foreground and background processes)| event | - **1**: event sending enabled
-**0**: event sending disabled| int | 0 or 1| + | name="process_ctrl" | Process control (survival status of foreground and background processes)| event | - **1**: event sending enabled
-**0**: event sending disabled
If this parameter is not set, the value is defaulted to **0**.| int | 0 or 1| | name="shut_down" | Shutdown control (device shutdown)| event | - **1**: event sending enabled
-**0**: event sending disabled| int | 0 or 1| | name="thermallevel" | Thermal level control (thermal level reporting)| event | - **1**: event sending enabled
-**0**: event sending disabled| int | 0 or 1| | name="popup" | Pop-up window control (pop-up window display)| N/A| N/A| N/A| N/A| @@ -67,7 +67,7 @@ The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/ma - + @@ -143,13 +143,14 @@ The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/ma name: volume uid: 2001,2002 strict: 0 enableEvent: 0 name: current protocol: sc,buck strict: 0 enableEvent: 1 name: voltage protocol: sc,buck strict: 0 enableEvent: 1 - name: process_ctrl params: 32,64,128,256 strict: 0 enableEvent: 0 + name: process_ctrl strict: 0 enableEvent: 0 name: shut_down strict: 0 enableEvent: 0 name: thermallevel strict: 0 enableEvent: 0 name: popup strict: 0 enableEvent: 0 ``` ## Reference + During development, you can refer to the [default thermal control configuration](https://gitee.com/openharmony/powermgr_thermal_manager/blob/master/services/native/profile/thermal_service_config.xml). Packing path: `/vendor/etc/thermal_config/hdf` -- GitLab