diff --git a/en/application-dev/connectivity/net-connection-manager.md b/en/application-dev/connectivity/net-connection-manager.md index 5ee75a717882c3344612e741b2e197fa6e57509d..c443c93759caddbc5203b65022426882c0bb960b 100644 --- a/en/application-dev/connectivity/net-connection-manager.md +++ b/en/application-dev/connectivity/net-connection-manager.md @@ -39,7 +39,7 @@ For the complete list of APIs and example code, see [Network Connection Manageme | ---- | ---- | ---- | | ohos.net.connection | function getDefaultNet(callback: AsyncCallback\): void; |Creates a **NetHandle** object that contains the **netId** of the default network. This API uses an asynchronous callback to return the result.| | ohos.net.connection | function getGlobalHttpProxy10+(callback: AsyncCallback\): void;| Obtains the global HTTP proxy for the network. This API uses an asynchronous callback to return the result.| -| ohos.net.connection | function setGlobalHttpProxy10+(httpProxy: HttpProxy, callback: AsyncCallback): void;| Sets the global HTTP proxy for the network. This API uses an asynchronous callback to return the result.| +| ohos.net.connection | function setGlobalHttpProxy10+(httpProxy: HttpProxy, callback: AsyncCallback\): void;| Sets the global HTTP proxy for the network. This API uses an asynchronous callback to return the result.| | ohos.net.connection | function getAppNet9+(callback: AsyncCallback\): void;| Obtains a **NetHandle** object that contains the **netId** of the network bound to the application. This API uses an asynchronous callback to return the result.| | ohos.net.connection | function setAppNet9+(netHandle: NetHandle, callback: AsyncCallback\): void;| Binds an application to the specified network. The application can access the external network only through this network. This API uses an asynchronous callback to return the result.| | ohos.net.connection | function getDefaultNetSync9+(): NetHandle; |Obtains the default active data network in synchronous mode. You can use **getNetCapabilities** to obtain information such as the network type and capabilities.| @@ -47,7 +47,7 @@ For the complete list of APIs and example code, see [Network Connection Manageme | ohos.net.connection | function getAllNets(callback: AsyncCallback\>): void;| Obtains the list of **NetHandle** objects of the connected network. This API uses an asynchronous callback to return the result.| | ohos.net.connection | function getConnectionProperties(netHandle: NetHandle, callback: AsyncCallback\): void; |Obtains link information of the default network. This API uses an asynchronous callback to return the result.| | ohos.net.connection | function getNetCapabilities(netHandle: NetHandle, callback: AsyncCallback\): void; |Obtains the capability set of the default network. This API uses an asynchronous callback to return the result.| -| ohos.net.connection | function isDefaultNetMetered9+(callback: AsyncCallback): void; |Checks whether the data traffic usage on the current network is metered. This API uses an asynchronous callback to return the result.| +| ohos.net.connection | function isDefaultNetMetered9+(callback: AsyncCallback\): void; |Checks whether the data traffic usage on the current network is metered. This API uses an asynchronous callback to return the result.| | ohos.net.connection | function reportNetConnected(netHandle: NetHandle, callback: AsyncCallback\): void;| Reports a **netAavailable** event to NetManager. If this API is called, the application considers that its network status (ohos.net.connection.NetCap.NET_CAPABILITY_VAILDATED) is inconsistent with that of NetManager. This API uses an asynchronous callback to return the result.| | ohos.net.connection | function reportNetDisconnected(netHandle: NetHandle, callback: AsyncCallback\): void;| Reports a **netAavailable** event to NetManager. If this API is called, the application considers that its network status (ohos.net.connection.NetCap.NET_CAPABILITY_VAILDATED) is inconsistent with that of NetManager. This API uses an asynchronous callback to return the result.| | ohos.net.connection | function getAddressesByName(host: string, callback: AsyncCallback\>): void; |Obtains all IP addresses of the specified network by resolving the domain name. This API uses an asynchronous callback to return the result.| diff --git a/en/application-dev/connectivity/net-mgmt-overview.md b/en/application-dev/connectivity/net-mgmt-overview.md index 043d41768f89dd851839eae893b7ba4409395f5e..f03d7668edc9fc27ef22c4ef4d69b186f7b4c3d9 100644 --- a/en/application-dev/connectivity/net-mgmt-overview.md +++ b/en/application-dev/connectivity/net-mgmt-overview.md @@ -5,7 +5,6 @@ Network management functions include: - [HTTP data request](http-request.md): initiates a data request through HTTP. - [WebSocket connection](websocket-connection.md): establishes a bidirectional connection between the server and client through WebSocket. - [Socket connection](socket-connection.md): transmits data through Socket. -- [Network policy management](net-policy-management.md): restricts network capabilities by setting network policies, including cellular network policy, sleep/power-saving mode policy, and background network policy, and resets network policies as needed. - [Network sharing](net-sharing.md): shares a device's Internet connection with other connected devices by means of Wi-Fi hotspot, Bluetooth, and USB sharing, and queries the network sharing state and shared mobile data volume. - [Ethernet connection](net-ethernet.md): provides wired network capabilities, which allow you to set the IP address, subnet mask, gateway, and Domain Name System (DNS) server of a wired network. - [Network connection management](net-connection-manager.md): provides basic network management capabilities, including management of Wi-Fi/cellular/Ethernet connection priorities, network quality evaluation, subscription to network connection status changes, query of network connection information, and DNS resolution. diff --git a/en/application-dev/device/usb-guidelines.md b/en/application-dev/device/usb-guidelines.md index 68c8c3de013e75d56854bf0cf0e3a71aca9eb261..ef09e1ee89940220f8b9d1936362d34ebf8bf7a6 100644 --- a/en/application-dev/device/usb-guidelines.md +++ b/en/application-dev/device/usb-guidelines.md @@ -1,156 +1,161 @@ # USB Service Development + ## When to Use In Host mode, you can obtain the list of connected USB devices, enable or disable the devices, manage device access permissions, and perform data transfer or control transfer. -## APIs + +## Available APIs The USB service provides the following functions: query of USB device list, bulk data transfer, control transfer, and access permission management. The following table lists the USB APIs currently available. For details, see the [API Reference](../reference/apis/js-apis-usbManager.md). -**Table 1** Open USB APIs +**Table 1** Open USB APIs -| API | Description | +| Name | Description | | ------------------------------------------------------------ | ------------------------------------------------------------ | -| hasRight(deviceName: string): boolean | Checks whether the user has the device access permissions. | -| requestRight(deviceName: string): Promise\ | Requests the temporary permission for a given application to access the USB device. This API uses a promise to return the result. | -| connectDevice(device: USBDevice): Readonly\ | Connects to the USB device based on the device list returned by `getDevices()`. | -| getDevices(): Array> | Obtains the list of USB devices connected to the USB host. If no USB device is connected, an empty list is returned. | -| setConfiguration(pipe: USBDevicePipe, config: USBConfiguration): number | Sets the USB device configuration. | -| setInterface(pipe: USBDevicePipe, iface: USBInterface): number | Sets a USB interface. | -| claimInterface(pipe: USBDevicePipe, iface: USBInterface, force ?: boolean): number | Claims a USB interface. | -| bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, timeout ?: number): Promise\ | Performs bulk transfer. | -| closePipe(pipe: USBDevicePipe): number | Closes a USB device pipe. | -| releaseInterface(pipe: USBDevicePipe, iface: USBInterface): number | Releases a USB interface. | -| getFileDescriptor(pipe: USBDevicePipe): number | Obtains the file descriptor. | -| getRawDescriptor(pipe: USBDevicePipe): Uint8Array | Obtains the raw USB descriptor. | -| controlTransfer(pipe: USBDevicePipe, controlparam: USBControlParams, timeout ?: number): Promise<number> | Performs control transfer. | +| hasRight(deviceName: string): boolean | Checks whether the user has the device access permissions.| +| requestRight(deviceName: string): Promise<boolean> | Requests the device access permissions for the application. This API uses a promise to return the result. | +| removeRight(deviceName: string): boolean | Revokes the device access permissions of the application.| +| connectDevice(device: USBDevice): Readonly<USBDevicePipe> | Connects to the USB device based on the device information returned by `getDevices()`. | +| getDevices(): Array<Readonly<USBDevice>> | Obtains the list of USB devices connected to the host. If no device is connected, an empty list is returned. | +| setConfiguration(pipe: USBDevicePipe, config: USBConfiguration): number | Sets the USB device configuration. | +| setInterface(pipe: USBDevicePipe, iface: USBInterface): number | Sets a USB interface. | +| claimInterface(pipe: USBDevicePipe, iface: USBInterface, force ?: boolean): number | Claims a USB interface. | +| bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, timeout ?: number): Promise<number> | Performs bulk transfer. | +| closePipe(pipe: USBDevicePipe): number | Closes a USB device pipe. | +| releaseInterface(pipe: USBDevicePipe, iface: USBInterface): number | Releases a USB interface. | +| getFileDescriptor(pipe: USBDevicePipe): number | Obtains the file descriptor. | +| getRawDescriptor(pipe: USBDevicePipe): Uint8Array | Obtains the raw USB descriptor. | +| controlTransfer(pipe: USBDevicePipe, controlparam: USBControlParams, timeout ?: number): Promise<number> | Performs control transfer. | + ## How to Develop -You can set a USB device as the USB host to connect to other USB devices for data transfer. The development procedure is as follows: - -1. Obtain the USB device list. - - ```js - // Import the USB API package. - import usb from '@ohos.usbManager'; - // Obtain the USB device list. - let deviceList = usb.getDevices(); - /* - Example deviceList structure - [ - { - name: "1-1", - serial: "", - manufacturerName: "", - productName: "", - version: "", - vendorId: 7531, - productId: 2, - clazz: 9, - subClass: 0, - protocol: 1, - devAddress: 1, - busNum: 1, - configs: [ - { - id: 1, - attributes: 224, - isRemoteWakeup: true, - isSelfPowered: true, - maxPower: 0, - name: "1-1", - interfaces: [ - { - id: 0, - protocol: 0, - clazz: 9, - subClass: 0, - alternateSetting: 0, - name: "1-1", - endpoints: [ - { - address: 129, - attributes: 3, - interval: 12, - maxPacketSize: 4, - direction: 128, - number: 1, - type: 3, - interfaceId: 0, - } - ] - } - ] - } - ] - } - ] - */ - ``` - +You can set a USB device as a host to connect to a device for data transfer. The development procedure is as follows: + + +1. Obtain the USB device list. + + ```js + // Import the USB API package. + import usb from '@ohos.usbManager'; + // Obtain the USB device list. + let deviceList = usb.getDevices(); + /* + Example deviceList structure: + [ + { + name: "1-1", + serial: "", + manufacturerName: "", + productName: "", + version: "", + vendorId: 7531, + productId: 2, + clazz: 9, + subClass: 0, + protocol: 1, + devAddress: 1, + busNum: 1, + configs: [ + { + id: 1, + attributes: 224, + isRemoteWakeup: true, + isSelfPowered: true, + maxPower: 0, + name: "1-1", + interfaces: [ + { + id: 0, + protocol: 0, + clazz: 9, + subClass: 0, + alternateSetting: 0, + name: "1-1", + endpoints: [ + { + address: 129, + attributes: 3, + interval: 12, + maxPacketSize: 4, + direction: 128, + number: 1, + type: 3, + interfaceId: 0, + } + ] + } + ] + } + ] + } + ] + */ + ``` 2. Obtain the device operation permissions. - ```js - let deviceName = deviceList[0].name; - // Request the permissions to operate a specified device. - usb.requestRight(deviceName).then(hasRight => { - console.info("usb device request right result: " + hasRight); - }).catch(error => { - console.info("usb device request right failed : " + error); - }); - ``` + ```js + let deviceName = deviceList[0].name; + // Request the permissions to operate a specified device. + usb.requestRight(deviceName).then(hasRight => { + console.info("usb device request right result: " + hasRight); + }).catch(error => { + console.info("usb device request right failed : " + error); + }); + ``` 3. Open the device. - ```js - // Open the device, and obtain the USB device pipe for data transfer. - let interface1 = deviceList[0].configs[0].interfaces[0]; - /* - Claim the corresponding interface from deviceList. - interface1 must be one present in the device configuration. - */ - usb.claimInterface(pipe, interface1, true); - ``` + ```js + // Open the device, and obtain the USB device pipe for data transfer. + let pipe = usb.connectDevice(deviceList[0]); + let interface1 = deviceList[0].configs[0].interfaces[0]; + /* + Claim the corresponding interface from **deviceList**. + interface1 must be one present in the device configuration. + */ + usb.claimInterface(pipe, interface1, true); + ``` 4. Perform data transfer. - ```js - /* + ```js + /* Read data. Select the corresponding RX endpoint from deviceList for data transfer. - (endpoint.direction == 0x80); dataUint8Array indicates the data to read. The data type is Uint8Array. - */ - let inEndpoint = interface1.endpoints[2]; - let outEndpoint = interface1.endpoints[1]; - let dataUint8Array = new Uint8Array(1024); - usb.bulkTransfer(pipe, inEndpoint, dataUint8Array, 15000).then(dataLength => { - if (dataLength >= 0) { - console.info("usb readData result Length : " + dataLength); - } else { - console.info("usb readData failed : " + dataLength); - } - }).catch(error => { - console.info("usb readData error : " + JSON.stringify(error)); - }); - // Send data. Select the corresponding TX endpoint from deviceList for data transfer. (endpoint.direction == 0) - usb.bulkTransfer(pipe, outEndpoint, dataUint8Array, 15000).then(dataLength => { - if (dataLength >= 0) { - console.info("usb writeData result write length : " + dataLength); - } else { - console.info("writeData failed"); - } - }).catch(error => { - console.info("usb writeData error : " + JSON.stringify(error)); - }); - ``` - -5. Release the USB interface, and close the USB device. - - ```js - usb.releaseInterface(pipe, interface); - usb.closePipe(pipe); - ``` \ No newline at end of file + (endpoint.direction == 0x80); dataUint8Array indicates the data to read. The data type is Uint8Array. + */ + let inEndpoint = interface1.endpoints[2]; + let outEndpoint = interface1.endpoints[1]; + let dataUint8Array = new Uint8Array(1024); + usb.bulkTransfer(pipe, inEndpoint, dataUint8Array, 15000).then(dataLength => { + if (dataLength >= 0) { + console.info("usb readData result Length : " + dataLength); + } else { + console.info("usb readData failed : " + dataLength); + } + }).catch(error => { + console.info("usb readData error : " + JSON.stringify(error)); + }); + // Send data. Select the corresponding TX endpoint from deviceList for data transfer. (endpoint.direction == 0) + usb.bulkTransfer(pipe, outEndpoint, dataUint8Array, 15000).then(dataLength => { + if (dataLength >= 0) { + console.info("usb writeData result write length : " + dataLength); + } else { + console.info("writeData failed"); + } + }).catch(error => { + console.info("usb writeData error : " + JSON.stringify(error)); + }); + ``` + +5. Release the USB interface, and close the USB device. + + ```js + usb.releaseInterface(pipe, interface1); + usb.closePipe(pipe); + ``` \ No newline at end of file diff --git a/en/application-dev/internationalization/intl-guidelines.md b/en/application-dev/internationalization/intl-guidelines.md index fcac5325292b27f349f6c3dcadb627dca2dd0c03..44b69713783501cc21c0612fa2bb08390a53dcc0 100644 --- a/en/application-dev/internationalization/intl-guidelines.md +++ b/en/application-dev/internationalization/intl-guidelines.md @@ -111,7 +111,7 @@ The [i18n](../reference/apis/js-apis-i18n.md) module provides enhanced I18N capa let dateTimeFormat = new Intl.DateTimeFormat(); ``` - Alternatively, use your own locale and formatting parameters to create a **DateTimeFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [DateTimeOptions](../reference/apis/js-apis-intl.md#datetimeoptions9). + Alternatively, use your own locale and formatting parameters to create a **DateTimeFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [DateTimeOptions](../reference/apis/js-apis-intl.md#datetimeoptions6). ```js let options = {dateStyle: "full", timeStyle: "full"}; @@ -181,7 +181,7 @@ The [i18n](../reference/apis/js-apis-i18n.md) module provides enhanced I18N capa let numberFormat = new Intl.NumberFormat(); ``` - Alternatively, use your own locale and formatting parameters to create a **NumberFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [NumberOptions](../reference/apis/js-apis-intl.md#numberoptions9). + Alternatively, use your own locale and formatting parameters to create a **NumberFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [NumberOptions](../reference/apis/js-apis-intl.md#numberoptions6). ```js let options = {compactDisplay: "short", notation: "compact"}; @@ -240,7 +240,7 @@ Users in different regions have different requirements for string sorting. [Coll let collator = new Intl.Collator(); ``` - Alternatively, use your own locale and formatting parameters to create a **Collator** object. For a full list of parameters, see [CollatorOptions](../reference/apis/js-apis-intl.md#collatoroptions9). + Alternatively, use your own locale and formatting parameters to create a **Collator** object. For a full list of parameters, see [CollatorOptions](../reference/apis/js-apis-intl.md#collatoroptions8). The **sensitivity** parameter is used to specify the levels of differences that will be used for string comparison. The value **base** indicates that only characters are compared, but not the accent and capitalization. For example, 'a' != 'b', 'a' == '', 'a'=='A'. The value **accent** indicates that the accent is considered, but not the capitalization. For example, 'a' != 'b', 'a' == '', 'a'=='A'. The value **case** indicates that the capitalization is considered, but the accent. For example, 'a' != 'b', 'a' == '', 'a'=='A'. The value **variant** indicates that the accent and capitalization are considered. For example, 'a' != 'b', 'a' == '', 'a'=='A'. ```js @@ -301,7 +301,7 @@ According to grammars in certain languages, the singular or plural form of a nou let pluralRules = new Intl.PluralRules(); ``` - Alternatively, use your own locale and formatting parameters to create a **PluralRules** object. For a full list of parameters, see [PluralRulesOptions](../reference/apis/js-apis-intl.md#pluralrulesoptions9). + Alternatively, use your own locale and formatting parameters to create a **PluralRules** object. For a full list of parameters, see [PluralRulesOptions](../reference/apis/js-apis-intl.md#pluralrulesoptions8). ```js let pluralRules = new Intl.PluralRules("zh-CN", {localeMatcher: "best fit", type: "cardinal"}); @@ -349,7 +349,7 @@ According to grammars in certain languages, the singular or plural form of a nou let relativeTimeFormat = new Intl.RelativeTimeFormat(); ``` - Alternatively, use your own locale and formatting parameters to create a **RelativeTimeFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [RelativeTimeFormatInputOptions](../reference/apis/js-apis-intl.md#relativetimeformatinputoptions9). + Alternatively, use your own locale and formatting parameters to create a **RelativeTimeFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [RelativeTimeFormatInputOptions](../reference/apis/js-apis-intl.md#relativetimeformatinputoptions8). ```js let relativeTimeFormat = new Intl.RelativeTimeFormat("zh-CN", {numeric: "always", style: "long"}); @@ -384,4 +384,4 @@ According to grammars in certain languages, the singular or plural form of a nou ```js let relativeTimeFormat = new Intl.RelativeTimeFormat("zh-CN", {numeric: "always", style: "long"}); let options = relativeTimeFormat.resolvedOptions(); // options = {"locale": "zh-CN", "style": "long", "numeric": "always", "numberingSystem": "latn"} - ``` + ``` \ No newline at end of file diff --git a/en/application-dev/reference/apis/Readme-EN.md b/en/application-dev/reference/apis/Readme-EN.md index 871c522053d2c728a21f4059ef73a0e75d6ed4e2..d7d6893761031ed88d0c4c79fdbcf3dec8d46bac 100644 --- a/en/application-dev/reference/apis/Readme-EN.md +++ b/en/application-dev/reference/apis/Readme-EN.md @@ -325,7 +325,7 @@ - [@ohos.systemTimer (System Timer)](js-apis-system-timer.md) - [@ohos.wallpaper (Wallpaper)](js-apis-wallpaper.md) - [@ohos.web.webview (Webview)](js-apis-webview.md) - - [console (Log)](js-apis-logs.md) + - [Console](js-apis-logs.md) - [Timer](js-apis-timer.md) - application - [AccessibilityExtensionContext (Accessibility Extension Context)](js-apis-inner-application-accessibilityExtensionContext.md) diff --git a/en/application-dev/reference/apis/js-apis-call.md b/en/application-dev/reference/apis/js-apis-call.md index 1f90664de26360d3099d9f0870baabaad1063b23..a488a313beff34555f589b57bdea17ddbdbcc752 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-intl.md b/en/application-dev/reference/apis/js-apis-intl.md index cec10d9eef5fbd50d9d81ca6a5358d57d78fdbf0..99131363c58faef8abe196d0e20e01b176a1258e 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-logs.md b/en/application-dev/reference/apis/js-apis-logs.md index b2d837bae04d378938b355d535971cf6d56e48c5..2048ba0468770a7d7d269241a42d85b31fc03b20 100644 --- a/en/application-dev/reference/apis/js-apis-logs.md +++ b/en/application-dev/reference/apis/js-apis-logs.md @@ -1,4 +1,4 @@ -# console (Log Printing) +# Console The **console** module provides basic log printing capabilities and supports log printing by log level. diff --git a/en/application-dev/reference/apis/js-apis-net-ethernet.md b/en/application-dev/reference/apis/js-apis-net-ethernet.md index ec15531de49c13ab4b2c85b0da9eacf37400d195..eca9a04d0e42791e19a3620f6582f3d7284dc6d4 100644 --- a/en/application-dev/reference/apis/js-apis-net-ethernet.md +++ b/en/application-dev/reference/apis/js-apis-net-ethernet.md @@ -55,8 +55,7 @@ ethernet.setIfaceConfig("eth0", { route: "192.168.xx.xxx", gateway: "192.168.xx.xxx", netMask: "255.255.255.0", - dnsServers: "1.1.1.1", - domain: "2.2.2.2" + dnsServers: "1.1.1.1" }, (error) => { if (error) { console.log("setIfaceConfig callback error = " + JSON.stringify(error)); @@ -115,8 +114,7 @@ ethernet.setIfaceConfig("eth0", { route: "192.168.xx.xxx", gateway: "192.168.xx.xxx", netMask: "255.255.255.0", - dnsServers: "1.1.1.1", - domain: "2.2.2.2" + dnsServers: "1.1.1.1" }).then(() => { console.log("setIfaceConfig promise ok "); }).catch(error => { @@ -168,7 +166,6 @@ ethernet.getIfaceConfig("eth0", (error, value) => { console.log("getIfaceConfig callback gateway = " + JSON.stringify(value.gateway)); console.log("getIfaceConfig callback netMask = " + JSON.stringify(value.netMask)); console.log("getIfaceConfig callback dnsServers = " + JSON.stringify(value.dnsServers)); - console.log("getIfaceConfig callback domain = " + JSON.stringify(value.domain)); } }); ``` @@ -219,7 +216,6 @@ ethernet.getIfaceConfig("eth0").then((data) => { console.log("getIfaceConfig promise gateway = " + JSON.stringify(data.gateway)); console.log("getIfaceConfig promise netMask = " + JSON.stringify(data.netMask)); console.log("getIfaceConfig promise dnsServers = " + JSON.stringify(data.dnsServers)); - console.log("getIfaceConfig promise domain = " + JSON.stringify(data.domain)); }).catch(error => { console.log("getIfaceConfig promise error = " + JSON.stringify(error)); }); diff --git a/en/application-dev/reference/apis/js-apis-system-fetch.md b/en/application-dev/reference/apis/js-apis-system-fetch.md index 96bc642f5214e48b09df204a314bd694677a77f4..316e9ca1b3a083d9fdb277b6d910019d229cbce7 100644 --- a/en/application-dev/reference/apis/js-apis-system-fetch.md +++ b/en/application-dev/reference/apis/js-apis-system-fetch.md @@ -16,47 +16,15 @@ import fetch from '@system.fetch'; ## fetch.fetch3+ -fetch(options:{ - /** - * Resource URL. - * @since 3 - */ - url: string; - /** - * Request parameter, which can be of the string type or a JSON object. - * @since 3 - */ - data?: string | object; - /** - * Request header, which accommodates all attributes of the request. - * @since 3 - */ - header?: Object; - /** - * Request methods available: OPTIONS, GET, HEAD, POST, PUT, DELETE and TRACE. The default value is GET. - * @since 3 - */ - method?: string; - /** - * The return type can be text, or JSON. By default, the return type is determined based on Content-Type in the header returned by the server. - * @since 3 - */ - responseType?: string; - /** - * Called when the network data is obtained successfully. - * @since 3 - */ - success?: (data: FetchResponse) => void; - /** - * Called when the network data fails to be obtained. - * @since 3 - */ - fail?: (data: any, code: number) => void; - /** - * Called when the execution is completed. - * @since 3 - */ - complete?: () => void; +fetch(options:{
+  url: string;
+  data?: string | object;
+  header?: Object;
+  method?: string;
+  responseType?: string;
+  success?: (data: FetchResponse) => void;
+  fail?: (data: any, code: number) => void;
+  complete?: () => void;
} ): void Obtains data through a network. diff --git a/en/application-dev/reference/apis/js-apis-system-network.md b/en/application-dev/reference/apis/js-apis-system-network.md index 232c2be8d60b3b893fbebc1119b7d9e807d80ddf..e0cc9a177547c86910db7b3ba4c8ac5e8eb97e75 100644 --- a/en/application-dev/reference/apis/js-apis-system-network.md +++ b/en/application-dev/reference/apis/js-apis-system-network.md @@ -1,8 +1,6 @@ # @system.network (Network State) > **NOTE** -> - The APIs of this module are no longer maintained since API version 7. You are advised to use [`@ohos.telephony.observer`](js-apis-observer.md). -> > - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -23,23 +21,11 @@ ohos.permission.GET_NETWORK_INFO ## network.getType3+ -getType(options?: { - /** - * Called when the network type is obtained. - * @since 3 - */ - success?: (data: NetworkResponse) => void; - /** - * Called when the network type fails to be obtained. - * @since 3 - */ - fail?: (data: any, code: number) => void; - /** - * Called when the execution is completed. - * @since 3 - */ - complete?: () => void; - }): void +getType(options?: {
+  success?: (data: NetworkResponse) => void;
+  fail?: (data: any, code: number) => void;
+  complete?: () => void;
+}): void Obtains the network type. @@ -79,17 +65,9 @@ export default { ## network.subscribe3+ -subscribe(options?:{ - /** - * Called when the network connection state changes. - * @since 3 - */ - success?: (data: NetworkResponse) => void; - /** - * Called when the listening fails. - * @since 3 - */ - fail?: (data: any, code: number) => void; +subscribe(options?:{
+  success?: (data: NetworkResponse) => void;
+  fail?: (data: any, code: number) => void;
}): void Listens to the network connection state. If this method is called multiple times, the last call takes effect. diff --git a/en/application-dev/reference/errorcodes/errorcode-multimodalinput.md b/en/application-dev/reference/errorcodes/errorcode-multimodalinput.md index 6933bfcf7075ca21cf7a63959f11059da061ff36..4c269a4a723459598a3f1117b820881619be648f 100644 --- a/en/application-dev/reference/errorcodes/errorcode-multimodalinput.md +++ b/en/application-dev/reference/errorcodes/errorcode-multimodalinput.md @@ -1,4 +1,4 @@ -# Screen Hopping Error Codes +# Screen Hopping Error Codes (To Be Deprecated) > **NOTE** > diff --git a/en/application-dev/task-management/transient-task-dev-guide.md b/en/application-dev/task-management/transient-task-dev-guide.md index a83ba2094138e2271f55758484f483a9a7ddbaed..cb540210efac85a45f709b878b6b85dcf9024084 100644 --- a/en/application-dev/task-management/transient-task-dev-guide.md +++ b/en/application-dev/task-management/transient-task-dev-guide.md @@ -6,7 +6,7 @@ By default, an application can run for a period of 6 to 12 seconds after it swit You are advised not to call the [requestSuspendDelay()](../reference/apis/js-apis-resourceschedule-backgroundTaskManager.md#backgroundtaskmanagerrequestsuspenddelay) method to apply for delayed suspension after the application is running in the background. Instead, you need to call this interface to declare the execution time of the extended application to the system before performing any time-consuming operation. It is recommended that an application calls [requestSuspendDelay()](../reference/apis/js-apis-resourceschedule-backgroundTaskManager.md#backgroundtaskmanagerrequestsuspenddelay) when it is running in the foreground, so as not to affect the transient task quota of the application. -An application can obtain the remaining duration before being suspended by calling [getRemainingDelayTime()](../reference/apis/js-apis-resourceschedule-backgroundTaskManager.md#backgroundtaskmanagergetremainingdelaytimecallback). Each application has a daily time quota for transient tasks. Therefore, after the time-consuming task finishes execution, the application should call [cancelSuspendDelay()](../reference/apis/js-apis-resourceschedule-backgroundTaskManager.md#backgroundtaskmanagercancelsuspenddelay) to cancel the transient task in a timely manner. +An application can obtain the remaining duration before being suspended by calling [getRemainingDelayTime()](../reference/apis/js-apis-resourceschedule-backgroundTaskManager.md#backgroundtaskmanagergetremainingdelaytime). Each application has a daily time quota for transient tasks. Therefore, after the time-consuming task finishes execution, the application should call [cancelSuspendDelay()](../reference/apis/js-apis-resourceschedule-backgroundTaskManager.md#backgroundtaskmanagercancelsuspenddelay) to cancel the transient task in a timely manner. Typical time-consuming tasks include saving status data to the local database, opening and processing a large file, and synchronizing data to the cloud server. diff --git a/en/application-dev/telephony/telephony-sms.md b/en/application-dev/telephony/telephony-sms.md index 714d2f182b9e5452065db19f171b5dc45e522f73..400f06ac804cbbcf5875cdca518dec3cf978cc2a 100644 --- a/en/application-dev/telephony/telephony-sms.md +++ b/en/application-dev/telephony/telephony-sms.md @@ -31,11 +31,11 @@ The Short Messaging Service (SMS) module provides basic SMS management functions | Name | Description | | ------------------------------------------------------------ | ------------------------------------------------------- | -| createMessage(pdu: Array, specification: string, callback: AsyncCallback): void | Creates an SMS message instance based on the PDU and the specified SMS protocol.| +| createMessage(pdu: Array, specification: string, callback: AsyncCallback\): void | Creates an SMS message instance based on the PDU and the specified SMS protocol.| | sendMessage(options: SendMessageOptions): void | Sends text or data SMS messages. | -| getDefaultSmsSlotId(callback: AsyncCallback): void | Obtains the ID of the default SIM card used to send SMS messages. | -| setSmscAddr(slotId: number, smscAddr: string, callback: AsyncCallback): void | Sets the SMSC address based on the specified slot ID. | -| getSmscAddr(slotId: number, callback: AsyncCallback): void | Obtains the SMSC address based on the specified slot ID. | +| getDefaultSmsSlotId(callback: AsyncCallback\): void | Obtains the ID of the default SIM card used to send SMS messages. | +| setSmscAddr(slotId: number, smscAddr: string, callback: AsyncCallback\): void | Sets the SMSC address based on the specified slot ID. | +| getSmscAddr(slotId: number, callback: AsyncCallback\): void | Obtains the SMSC address based on the specified slot ID. | ## How to Develop diff --git a/en/application-dev/website.md b/en/application-dev/website.md index ce81eabf772ff5954646408aba1cc9b0dadd658d..f8e6f89f51a8ac406def90fb058ce2f80f2d5c73 100644 --- a/en/application-dev/website.md +++ b/en/application-dev/website.md @@ -1289,7 +1289,7 @@ - [@ohos.systemTimer (System Timer)](reference/apis/js-apis-system-timer.md) - [@ohos.wallpaper (Wallpaper)](reference/apis/js-apis-wallpaper.md) - [@ohos.web.webview (Webview)](reference/apis/js-apis-webview.md) - - [console (Log)](reference/apis/js-apis-logs.md) + - [Console](reference/apis/js-apis-logs.md) - [Timer](reference/apis/js-apis-timer.md) - application - [AccessibilityExtensionContext](reference/apis/js-apis-inner-application-accessibilityExtensionContext.md) diff --git a/en/device-dev/subsystems/subsys-boot-init-seccomp.md b/en/device-dev/subsystems/subsys-boot-init-seccomp.md index 33f566d8c2e638d3ec384c3990b046f97dcb628d..9ba6a0ed8a5ce8d3f84515e32de5d7b4fb043141 100644 --- a/en/device-dev/subsystems/subsys-boot-init-seccomp.md +++ b/en/device-dev/subsystems/subsys-boot-init-seccomp.md @@ -1,29 +1,21 @@ # Seccomp Policy Development - ## Overview - ### Introduction - Secure computing mode (Seccomp) is a security mechanism provided by the Linux kernel. In the Linux system, a large number of system calls can be opened to user-mode programs without any restrictions. However, not all of these system calls are necessarily needed for user-mode programs. In this case, abuse of system calls can lead to system threats. For example, if a process has a security vulnerability, an attacker can run a shellcode segment to trigger system calls that are not triggered during normal execution, resulting in privilege escalation or private information leakage. To prevent such security risks, Seccomp limits the scope of system calls that can be used by programs, so as to reduce system exposure and improve security. ### Operating Mechanism +1. Basic mechanism -- Basic mechanism - - Seccomp policies exist in the form of policy files. During compilation and building, a policy file is parsed to generate a source file that contains the BPF instruction policies, and then the source file is compiled into a dynamic policy library. During startup of a user-mode process, Seccomp system calls are invoked to load the BPF instruction policies into the kernel through the dynamic policy library. - -- Basic features + Seccomp policies exist in the form of policy files. During compilation and building, a policy file is parsed to generate a source file that contains the BPF instruction policies, and then the source file is compiled into a dynamic policy library. During startup of a user-mode process, Seccomp system calls are invoked to load the BPF instruction policies into the kernel through the dynamic policy library. - - A child process inherits the Seccomp policies of its parent process. - - After a Seccomp policy is loaded to the kernel during process running, the policy exists in the memory as a singly linked list and cannot be modified. - - Seccomp policies can be set for a process for multiple times. When a process executes a system call, the kernel traverses the policies specified for the nodes in the singly linked list, and then compares the policies to obtain the policy with the highest priority. +2. Basic features + - A child process inherits the Seccomp policies of its parent process. + - After a Seccomp policy is loaded to the kernel during process running, the policy exists in the memory as a singly linked list and cannot be modified. + - Seccomp policies can be set for a process for multiple times. When a process executes a system call, the kernel traverses the policies specified for the nodes in the singly linked list, and then compares the policies to obtain the policy with the highest priority. ### Constraints - -- System restrictions - - The system used must be a standard system, and the options listed below must be enabled in the kernel. You can find the kernel option configuration file of the product in **//kernel/linux/config/{linux_version}/arch/{target_cpu}/configs/**. +- System restrictions
The system used must be a standard system, and the options listed below must be enabled in the kernel. You can find the kernel option configuration file of the product in **//kernel/linux/config/{linux_version}/arch/{target_cpu}/configs/**. ```shell CONFIG_HAVE_ARCH_SECCOMP=y CONFIG_HAVE_ARCH_SECCOMP_FILTER=y @@ -32,7 +24,6 @@ Secure computing mode (Seccomp) is a security mechanism provided by the Linux ke ``` - Feature restrictions - - The Seccomp policy for non-privileged processes complies with the baseline blocklist mechanism. - If a process needs to use system calls in the baseline blocklist, the system calls must be declared in the privileged process policy file. - The same Seccomp policy is enabled for all application processes. @@ -40,13 +31,9 @@ Secure computing mode (Seccomp) is a security mechanism provided by the Linux ke - Personalized Seccomp policies can be enabled for the native service processes incubated by the init process. ## Enabling Seccomp - ### When to Use - To meet product security requirements, you can enable Seccomp to limit the scope of system calls that can be invoked by processes. The development procedure below describes how to enable the basic functions and policies of Seccomp. Note that the basic functions must meet the feature restrictions described in [Constraints](#constraints). For details about the basic policy file, see [Policy File Overview](#policy-file-overview). - ### How to Develop - 1. Add the following field to **vendor/Product vendor/Product name/config.json**: ```c "build_seccomp": true @@ -74,18 +61,14 @@ To meet product security requirements, you can enable Seccomp to limit the scope ] } ``` - 2. Perform a full build on the product code to generate an image. ``` ./build.sh --product-name *product name* --ccache --build-target make_all --target-cpu *specified CPU* ``` - 3. Burn the image into the device. ### Debugging and Verification - Check whether Seccomp is enabled for application processes and system service processes. - 1. Run the shell command to obtain the process ID (that is, **target pid**) of the target process. ``` ps -ef | grep xxx @@ -108,34 +91,30 @@ Check whether Seccomp is enabled for application processes and system service pr **Table 1** Description of the Seccomp status | Parameter | Description | | --- | --- | - | Seccomp | Whether Seccomp is enabled.
- **0**: disabled.
- **1**: enabled with the strict mode. Only the read, write, exit, and sigreturn system calls are allowed.
- **2**: enabled with the filter mode. The customized policies can be enabled by loading BPF instruction sets. | + | Seccomp | - **0**: disabled.
- **1**: enabled with the strict mode. Only the read, write, exit, and sigreturn system calls are allowed.
- **2**: enabled with the filter mode. The customized policies can be enabled by loading BPF instruction sets. | | Seccomp_filters | Number of Seccomp policies set for a process. | ## Customizing Seccomp Policies for a Process - ### When to Use - If the basic Seccomp policy has been enabled for a product, you can customize Seccomp policies for native service processes incubated by the init process to adapt to diversified security requirements. In this case, the Seccomp policies of other native service processes remain unchanged. - ### How to Develop 1. Collect statistics on the system calls required by the 32-bit and 64-bit systems by using the static analysis and Strace statistics methods described in [System Call Statistic Methods](#system-call-statistic-methods). In this way, you will obtain the initial Seccomp policy. 2. Write a policy file. For details, see [How to Write a Common Policy File](#how-to-write-a-common-policy-file). 3. Write and build the **BUILD.gn** file. - 1. Store the policy file in the code repository of the service subsystem and create a **BUILD.gn** file. For example, create the **seccomp_policy** folder in the service code repository, and create the policy file and **BUILD.gn** file in the folder. + 1. Store the policy file in the code repository of the service subsystem and create a **BUILD.gn** file. For example, create the **seccomp_policy** folder in the service code repository, and create the policy file and **BUILD.gn** file in the folder. ```shell //path/to/code/seccomp_policy ├── BUILD.gn └── example.seccomp.policy ``` - 2. To parse the policy file and build the policy dynamic library, use the **ohos_prebuilt_seccomp** template to declare the Seccomp policy file path of the process in the **BUILD.gn** file. The **ohos_prebuilt_seccomp** template is defined in the **//base/startup/init/services/modules/seccomp/scripts/seccomp_policy_fixer.gni** file. The following table describes the parameters in the template. **Table 2** Parameters in the ohos_prebuilt_seccomp template | Parameter | Description | | --- | --- | - | sources | Path of the policy configuration file, mandatory. | + | sources | Path of the policy configuration file, mandatory.| | filtername | Filter name, mandatory. The value must be the same as the value of **Services name** in the [boot configuration file](subsys-boot-init-cfg.md) of the process. Otherwise, the attempt to enable Seccomp will fail. This parameter determines the name of the dynamic policy library generated after the build. For example, if **filtername** is set to **xxx**, the name of the dynamic policy library is **libxxx_filter.z.so**. | | process_type | Process type, mandatory. If the process is one incubated by the init process, set this parameter to **system**; if the process is an application process, set this parameter to **app**.| | part_name | Part name, mandatory. | @@ -143,7 +122,7 @@ If the basic Seccomp policy has been enabled for a product, you can customize Se | install_enable | Option specifying whether to install the policy file to the image, mandatory. Set the value to **true**. | | install_images | Installation location in the image, mandatory. | - For example: + Example ```python #Import the template file. import("//base/startup/init/services/modules/seccomp/scripts/seccomp_policy_fixer.gni") @@ -163,7 +142,6 @@ If the basic Seccomp policy has been enabled for a product, you can customize Se install_images = [ "xxxxx" ] } ``` - 3. Add the build target of **xxxx_seccomp_filter** to other **BUILD.gn** files. ```python if (build_seccomp) { @@ -174,12 +152,10 @@ If the basic Seccomp policy has been enabled for a product, you can customize Se ```shell ./build.sh --product-name *product name* --ccache --build-target xxxx_seccomp_filter --target-cpu *specified CPU* ``` - If an error message that contains the following information is reported, the process needs to use the system calls in the baseline blocklist. In such a case, you need to declare the corresponding system call in **privileged_process.seccomp.policy**. For details, see [How to Write a Privileged Process Policy File](#how-to-write-a-privileged-process-policy-file). After the declaration is done, try again until the build is successful. ```shell xx of allow list is in block list ``` - 5. Use the hdc tool to push the dynamic policy library to the device and restart the device. ```shell # Push an appropriate library path based on the installation location in the image. For example, if the image is **system** and the system architecture is 32-bit, the path of the dynamic policy library is **/system/lib/seccomp/**. @@ -187,19 +163,15 @@ If the basic Seccomp policy has been enabled for a product, you can customize Se hdc file send /path/to/libxxx_filter.z.so /path/to/lib(or lib64)/seccomp/ hdc shell reboot ``` - 6. Use the [audit statistics](#audit-statistics) method to check and supplement the Seccomp policies. Repeat steps 4 to 6 until the process can run properly. ### Debugging and Verification - 1. If Seccomp is not enabled for the target process, [check the Seccomp status](#debugging-and-verification) of the target process. 2. If the process is terminated and audit log information is present in the kernel logs, the Seccomp policy is enabled but the policy list is incomplete. You can find an example audit log in [Audit Statistics](#audit-statistics). 3. If the process is not terminated, comment out the system calls (for example, **setuid**) related to the specified uid in the Seccomp policy file. Rebuild the dynamic policy library, push the library to the image, and restart the process. Then, check whether the process is terminated by Seccomp. If the process is terminated, Seccomp has been enabled. ## FAQs - ### How do I determine whether a process termination is caused by Seccomp? - **Symptom** If a process is terminated under certain conditions, how do I determine whether the issue is caused by Seccomp? @@ -235,9 +207,7 @@ Use either of the following methods: ``` ## Reference - ### Seccomp source code directory - ``` base/startup/init/services/modules/seccomp ├── BUILD.gn @@ -259,11 +229,7 @@ base/startup/init/services/modules/seccomp ``` ### Policy File Overview - -- Location - - Basic policy files are stored in **//base/startup/init/services/modules/seccomp/seccomp_policy**. - +- Location
Basic policy files are stored in **//base/startup/init/services/modules/seccomp/seccomp_policy**. - Basic policy files **Table 3** Description of policy files @@ -278,7 +244,6 @@ base/startup/init/services/modules/seccomp | privileged_process.seccomp.policy | Privileged process policy file. If certain processes need to use the system calls on the baseline blocklist, you need to declare the corresponding process identifiers and baseline blocklists in this file.| ### How to Write a Common Policy File - - To declare a configuration item, write **@** followed by the configuration item, for example, **@returnValue**. - Add the content of a configuration item from the next line of this configuration item to the beginning of the next configuration item. - To comment out a line, add a pound sign (#) at the beginning of this line. @@ -333,7 +298,6 @@ swapon;all ``` ### How to Write a Privileged Process Policy File - - To declare a configuration item, write **@** followed by the configuration item, for example, **@allowBlockList**. - Add the content of a configuration item from the next line of this configuration item to the beginning of the next configuration item. - To comment out a line, add a pound sign (#) at the beginning of this line. @@ -362,32 +326,30 @@ swapon;all ``` ### System Call Statistic Methods - **Table 6** Comparison of statistic methods | Statistic Method | Description | Advantage | Disadvantage | | --- | --- | --- | --- | |
Static analysis |
Analyze the ELF disassembly code to obtain the call relationship, collect statistics on the APIs that call the libc library, and then parse the LibC library to obtain the call relationship between the LibC APIs and the system call numbers. In this way, you will obtain the system call numbers used by the ELF file.|
Statistics collection is supported for system calls in abnormal branches. |
Parsing of call relationship is not supported for pointer functions. | -| Strace statistics | Use Strace to trace service processes or test processes when the device is running. During the trace, the invoked system calls are recorded into logs. Collect the logs after the trace is complete, and use a script to parse the logs and generate a Seccomp policy file.| Easy to use. | System calls can be completely collected only when all code branches are traversed. | +| Strace statistics | Use Strace to trace service processes when the device is running. During the trace, the invoked system calls are recorded into logs. Collect the logs after the trace is complete, and use a script to parse the logs and generate a Seccomp policy file.| Easy to use. | System calls can be completely collected only when all code branches are traversed. | | Audit statistics | After the Seccomp policy is enabled for a process, Seccomp intercepts invalid system calls and records audit log information containing the system call numbers into kernel logs. Collect the logs after the trace is complete, and use a script to parse the logs and generate a Seccomp policy file.| This method can be used as a supplement to the preceding methods. | Logs may be lost.
System calls can be completely collected only when all code branches are traversed. | -> **Disclaimer: Using Third-Party Software or Websites** -> -> We may recommend software, information, products, or websites owned or operated by third parties. Such recommendations are usually provided via hyperlinks or other methods to help you access third-party resources.
-> We strive to direct you to useful and trusted resources, but it is beyond our reach to guarantee the software, information, products, or services provided by or at third-party resources, or to track changes in these resources. Therefore, we are unable to assume the responsibility for the compliance, accuracy, and completeness of the content or results of any third-party resources, nor for any loss or damage caused by the use or failure of products or services provided by third-party resources. - #### Static Analysis - 1. Prepare the environment. 1. Prepare a Linux environment. 2. Download the cross compilers arm-linux-musleabi and aarch64-linux-musl. ```shell + wget https://musl.cc/arm-linux-musleabi-cross.tgz + wget https://musl.cc/aarch64-linux-musl-cross.tgz + + tar -zxvf arm-linux-musleabi-cross.tgz + tar -zxvf aarch64-linux-musl-cross.tgz + # Add the tool execution path to the environment variable. export PATH=$PATH:/path/to/arm-linux-musleabi-cross/bin export PATH=$PATH:/path/to/aarch64-linux-musl-cross/bin ``` - 3. Download the OpenHarmony source code. - For details, see [Obtaining Source Code](../get-code/sourcecode-acquire.md). + 3. Download the OpenHarmony source code. For details, see [Obtaining Source Code](../get-code/sourcecode-acquire.md). 2. Compile **seccomp_filter** to obtain the dependency files **libsyscall_to_nr_arm** and **libsyscall_to_nr_arm64**. @@ -399,10 +361,10 @@ swapon;all cp out/*product name* /gen/base/startup/init/services/modules/seccomp/gen_system_filter/libsyscall_to_nr_arm* base/startup/init/services/modules/seccomp/scripts/tools/ ``` -3. Copy the **generate_code_from_policy.py** script file to the tool folder. This script is available at **//base/startup/init/services/modules/seccomp/scripts/**. +3. Copy the **generate_code_from_policy.py** script file to the tool folder. This script file is available at **//base/startup/init/services/modules/seccomp/scripts/**. ```shell # Go to the root directory of the OpenHarmony source code. - cd /root/to/OpenharmonyCode; + cd /root/to/OpenHarmonyCode; # Go to the directory where the **generate_code_from_policy.py** script file is located. cd base/startup/init/services/modules/seccomp/scripts/; # Copy the **generate_code_from_policy.py** script file. @@ -414,22 +376,31 @@ swapon;all ./build.sh --product-name *product file* --ccache --target-cpu arm64 --build-target *target file* ``` -5. Modify the **collect_elf_syscall.py** script file, and change the paths of the objdump and readelf tools to their absolute paths in the Linux environment. The tools are stored in **//prebuilts**, and more particularly, **//prebuilts/clang/ohos/linux-x86_64/15.0.4/llvm/bin**. +5. If full build has not been performed before and the dependent dynamic libraries for step 4 are not in the **//out** directory, copy the related dynamic libraries to the **//out** directory. The following code is for reference only. If other dynamic libraries are involved, copy them in a similar way. + ```shell + # Go to the root directory of the source code. + cd /root/to/OpenHarmonyCode + # Create the **aarch64-linux-ohos** folder in **out/*product name*/lib.unstripped/** to store the dependent dynamic libraries. + mkdir out/*product name*/lib.unstripped/aarch64-linux-ohos + # Copy the related dynamic libraries to the //out directory. + cp prebuilts/clang/ohos/${host_platform_dir}/llvm/lib/clang/${clang_version}/lib/aarch64-linux-ohos/*.so out/*product name*/lib.unstripped/aarch64-linux-ohos/ + cp prebuilts/clang/ohos/${host_platform_dir}/${clang_version}/llvm/lib/aarch64-linux-ohos/*.so out/*product name*/lib.unstripped/aarch64-linux-ohos/ + ``` + +6. Modify the **collect_elf_syscall.py** script file, and change the paths of the objdump and readelf tools to their absolute paths in the Linux environment. This script file is available at **base/startup/init/services/modules/seccomp/scripts/tools/**. The **objdump** and **readelf** tools available at **//prebuilts**. ```python #modified the path of objdump and readelf path def get_obj_dump_path(): - obj_dump_path = '/path/to/prebuilts/clang/ohos/linux-x86_64/15.0.4/llvm/bin/llvm-objdump' + obj_dump_path = '/path/to/llvm-objdump' return obj_dump_path def get_read_elf_path(): - read_elf_path = '/path/to/prebuilts/clang/ohos/linux-x86_64/15.0.4/llvm/bin/llvm-readelf' + read_elf_path = '/path/to/llvm-readelf' return read_elf_path ``` -6. Use the **collect_elf_syscall.py** script file to parse and generate the corresponding policy file **xxx.seccomp.policy**. - - The script file is available at **//base/startup/init/services/modules/seccomp/scripts/tools/**. +7. Use the **collect_elf_syscall.py** script file to parse and generate the corresponding policy file **xxx.seccomp.policy**. **Table 7** Parameters in the collect_elf_syscall.py script file | Parameter | Description | @@ -462,59 +433,10 @@ swapon;all ``` #### Strace Statistics - 1. Use the cross compilers arm-linux-musleabi and aarch64-linux-musl to build the Strace tool for the 32-bit and 64-bit architectures, respectively. -2. [Trace the test process](#tracing-the-test-process) to obtain Strace logs. -3. [Trace the service process](#tracing-the-service-process) to obtain the Strace logs. -4. [Parse Strace logs](#parsing-strace-logs) by using scripts to obtain the Seccomp policy file. - -##### Tracing the Test Process - -1. Push the Strace tool to the device. - ```shell - hdc shell mount -rw -o remount / - hdc file send /path/to/strace /system/bin/ - hdc shell chmod a+x /system/bin/strace - ``` - -2. Modify the local embedded code in the [developer test framework](https://gitee.com/openharmony/testfwk_developer_test) so that Strace is executed in the test suite to trace the test process. - - Modify the **_init_gtest** and **_run_gtest** functions in **src/core/driver/drivers.py** as follows. If a line starts with a plus sign (+), the line is added; if a line starts with a hyphen (-), the line is deleted. - - ```python - --- a/src/core/driver/drivers.py - +++ b/src/core/driver/drivers.py - @@ -500,6 +500,8 @@ class CppTestDriver(IDriver): - "rm -rf %s" % self.config.target_test_path) - self.config.device.execute_shell_command( - "mkdir -p %s" % self.config.target_test_path) - + self.config.device.execute_shell_command( - + "mkdir -p /data/strace") - self.config.device.execute_shell_command( - "mount -o rw,remount,rw /") - if "fuzztest" == self.config.testtype[0]: - @@ -539,10 +541,11 @@ class CppTestDriver(IDriver): - test_para, - seed) - else: - - command = "cd %s; rm -rf %s.xml; chmod +x *; ./%s %s" % ( - + command = "cd %s; rm -rf %s.xml; chmod +x *; strace -ff -o /data/strace/%s.strace.log ./%s %s" % ( - self.config.target_test_path, - filename, - filename, - + filename, - test_para) - else: - coverage_outpath = self.config.coverage_outpath - ``` -3. Execute related service test cases. -4. Obtain Strace logs from **/data/strace** on the device. - ```shell - hdc file recv /data/strace /path/to/base/startup/init/services/modules/seccomp/scripts/tools/ - ``` - +2. [Trace the service process](#tracing-the-service-process) to obtain the Strace logs. +3. [Parse Strace logs](#parsing-strace-logs) by using scripts to obtain the Seccomp policy file. ##### Tracing the Service Process - 1. Modify the embedded code in the init repository. Specifically, add the following content to **//base/startup/init/services/init/init_common_service.c** before executing the **SetSystemseccompPolicy** function to set the Seccomp policy. If the line starts with a plus sign (+), the line is added; if the line starts with a hyphen (-), the line is deleted. **xxxx** must be the same as the value of **Services name** in the [boot configuration file](subsys-boot-init-cfg.md) of the process. ```c --- a/services/init/init_common_service.c @@ -563,7 +485,6 @@ swapon;all ``` ##### Parsing Strace Logs - 1. Copy the dependency files to the Strace log folder for later use. The dependency files are those generated in step 2 in [Static Analysis](#static-analysis). ```shell cp out/*product name* /gen/base/startup/init/services/modules/seccomp/gen_system_filter/libsyscall_to_nr_arm* base/startup/init/services/modules/seccomp/scripts/tools/strace/ @@ -600,7 +521,6 @@ swapon;all ``` #### Audit Statistics - 1. Enable the initial Seccomp policy. For details, see [Customizing Seccomp Policies for a Process](#customizing-seccomp-policies-for-a-process). 2. Obtain logs. 1. Create a folder for storing logs. @@ -636,8 +556,7 @@ swapon;all Example audit log: ```shell - <5>[ 198.963101] audit: type=1326 audit(1659528178.748:27): auid=4294967295 uid=0 gid=1000 ses=4294967295 subj=u:r:appspawn:s0 pid=2704 comm="config_dialog_s" exe="/system/bin/appspawn" sig=31 arch=40000028 syscall= - 208 compat=1 ip=0xf7b79400 code=0x80000000 + <5>[ 198.963101] audit: type=1326 audit(1659528178.748:27): auid=4294967295 uid=0 gid=1000 ses=4294967295 subj=u:r:appspawn:s0 pid=2704 comm="config_dialog_s" exe="/system/bin/appspawn" sig=31 arch=40000028 syscall=208 compat=1 ip=0xf7b79400 code=0x80000000 ``` **Table 9** Key parameters in audit logs | Parameter | Description | @@ -646,7 +565,7 @@ swapon;all | sig | Semaphore. The value **31** indicates **SIGSYS**, which is the signal sent to the process when Seccomp interception occurs. | | arch | Architecture ID. The value **40000028** indicates **arm**, and the value **c00000b7** indicates **arm64**. | | syscall | System call ID. | - | compat | The value **1** indicates the compatibility mode, that is, the arm64 kernel uses arm system calls. | + | compat | The value **1** indicates the compatibility mode, that is, the arm64 kernel uses arm system calls.| 1. Copy the dependency files to the log folder for later use. The dependency files are those generated in step 2 in [Static Analysis](#static-analysis). @@ -659,7 +578,7 @@ swapon;all | Parameter | Description | | --- | --- | | --src-path | Folder for storing log files. It must contain **libsyscall_to_nr_arm** and **libsyscall_to_nr_arm64**. The folder name must not end with a slash (/), for example, **./audit**.| - | --filter-name | Name of the generated policy file. For example, if the input value is **test**, the generated file name is **test.seccomp.policy**. | + | --filter-name | Name of the generated policy file. For example, if the input value is **test**, the generated file name is **test.seccomp.policy**.| ```shell cd base/startup/init/services/modules/seccomp/scripts/tools @@ -667,7 +586,6 @@ swapon;all ``` ### Combining Multiple Policy Files - During [colltatistics on system calls](#system-call-statistic-methods), multiple policy files may be generated. In these policy files, system calls may be repeated or disordered. To solve these problems, you can combine policy files to sort system calls by arm64/arm and by system call number in ascending order. **Table 11** Parameters in the merge_policy.py script file @@ -675,7 +593,6 @@ During [colltatistics on system calls](#system-call-statistic-methods), multiple | --- | --- | | --src-files | Files to be processed, including **libsyscall_to_nr_arm** and **libsyscall_to_nr_arm64**.| | --filter-name | Name of the generated policy file. For example, if the input value is **test**, the generated file name is **test.seccomp.policy**. | - 1. Copy the dependency files to the log folder for later use. ```shell cp out/*product name* /gen/base/startup/init/services/modules/seccomp/gen_system_filter/libsyscall_to_nr_arm* base/startup/init/services/modules/seccomp/scripts/tools/ diff --git a/en/device-dev/subsystems/subsys-boot-init-sysparam.md b/en/device-dev/subsystems/subsys-boot-init-sysparam.md index 0dfc391b06ed14caf4bc5d0e17ce8a4654af723e..af860ca17d428c3f0d9b847dbebd0d2fc3a89fde 100644 --- a/en/device-dev/subsystems/subsys-boot-init-sysparam.md +++ b/en/device-dev/subsystems/subsys-boot-init-sysparam.md @@ -23,7 +23,7 @@ Figure 1 Overview of system parameter operation primitives | get | Obtains the value of a system parameter. | | set | Sets the value of a system parameter. | | wait | Waits for value change of a system parameter synchronously.| -| watch | Observes value change of a system parameter asynchronously.| +| watch | Watches for the value change of a system parameter asynchronously.| #### Parameter Definition @@ -227,7 +227,7 @@ The parameter management subsystem allows you to manage system parameters by run | param get [**key**] | Obtains the system parameter value of the specified key. If no key name is specified, all system parameter values will be returned.| | param set **key value** | Sets the specified value for the specified key.| | param wait **key** **value** | Waits for the system parameter value of the specified key to match the specified value. Fuzzy match is supported. For example, * indicates any value, and val* indicates matching of only the first three val characters.| - | param watch | Observes value change of a system parameter asynchronously.| + | param watch | Watches for the value change of a system parameter asynchronously.| - syspara API mode @@ -244,7 +244,7 @@ The parameter management subsystem allows you to manage system parameters by run | const char\* GetBrand(void) | Obtains the device's brand name.| | const char\* GetMarketName(void) | Obtains the device's marketing name.| | const char\* GetProductSeries(void) | Obtains the device's product series name.| - | const char\* GetProductModel(void) | Obtains the device's authentication model.| + | const char\* GetProductModel(void) | Obtains the device's product model.| | const char\* GetSoftwareModel(void) | Obtains the device's software model.| | const char\* GetHardwareModel(void) | Obtains the device's hardware model.| | const char\* GetHardwareProfile(void) | Obtains the device's hardware profile.|