提交 6d7b1c94 编写于 作者: G Gloria

Update docs against 20034+20424+20039

Signed-off-by: wusongqing<wusongqing@huawei.com>
上级 20357760
...@@ -49,10 +49,10 @@ Describes a rectangle on the display. ...@@ -49,10 +49,10 @@ Describes a rectangle on the display.
| Name | Type| Readable| Writable| Description | | Name | Type| Readable| Writable| Description |
| ------ | -------- | ---- | ---- | ------------------ | | ------ | -------- | ---- | ---- | ------------------ |
| left | number | Yes | Yes | Left boundary of the rectangle, in pixels.| | left | number | Yes | Yes | Left boundary of the rectangle, in pixels. The value must be an integer.|
| top | number | Yes | Yes | Top boundary of the rectangle, in pixels.| | top | number | Yes | Yes | Top boundary of the rectangle, in pixels. The value must be an integer.|
| width | number | Yes | Yes | Width of the rectangle, in pixels. | | width | number | Yes | Yes | Width of the rectangle, in pixels. The value must be an integer. |
| height | number | Yes | Yes | Height of the rectangle, in pixels. | | height | number | Yes | Yes | Height of the rectangle, in pixels. The value must be an integer. |
## WaterfallDisplayAreaRects<sup>9+</sup> ## WaterfallDisplayAreaRects<sup>9+</sup>
...@@ -196,7 +196,7 @@ Checks whether there is a visible privacy window on a display. The privacy windo ...@@ -196,7 +196,7 @@ Checks whether there is a visible privacy window on a display. The privacy windo
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------------------------- | ---- |----------| | ------ | ------------------------- | ---- |----------|
| id | number | Yes | ID of the display.| | id | number | Yes | ID of the display. The value must be an integer.|
**Return value** **Return value**
...@@ -248,10 +248,10 @@ Subscribes to display changes. ...@@ -248,10 +248,10 @@ Subscribes to display changes.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- |---------------------------------------------------------------------------------------------------------------------------------|
| type | string | Yes| Event type.<br>- **add**, indicating the display addition event. Example: event that a display is connected.<br>- **remove**, indicating the display removal event. Example: event that a display is disconnected.<br>- **change**, indicating the display change event. Example: event that the display orientation is changed.| | type | string | Yes| Event type.<br>- **add**, indicating the display addition event. Example: event that a display is connected.<br>- **remove**, indicating the display removal event. Example: event that a display is disconnected.<br>- **change**, indicating the display change event. Example: event that the display orientation is changed.|
| callback | Callback&lt;number&gt; | Yes| Callback used to return the ID of the display.| | callback | Callback&lt;number&gt; | Yes| Callback used to return the ID of the display, which is an integer. |
**Example** **Example**
...@@ -279,7 +279,7 @@ Unsubscribes from display changes. ...@@ -279,7 +279,7 @@ Unsubscribes from display changes.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Event type.<br>- **add**, indicating the display addition event. Example: event that a display is connected.<br>- **remove**, indicating the display removal event. Example: event that a display is disconnected.<br>- **change**, indicating the display change event. Example: event that the display orientation is changed.| | type | string | Yes| Event type.<br>- **add**, indicating the display addition event. Example: event that a display is connected.<br>- **remove**, indicating the display removal event. Example: event that a display is disconnected.<br>- **change**, indicating the display change event. Example: event that the display orientation is changed.|
| callback | Callback&lt;number&gt; | No| Callback used to return the ID of the display.| | callback | Callback&lt;number&gt; | No| Callback used to return the ID of the display, which is an integer.|
**Example** **Example**
...@@ -335,7 +335,7 @@ Unsubscribes from privacy mode changes of this display. When there is a privacy ...@@ -335,7 +335,7 @@ Unsubscribes from privacy mode changes of this display. When there is a privacy
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- |------------------------------------------| ---- | ------------------------------------------------------- | | -------- |------------------------------------------| ---- | ------------------------------------------------------- |
| type | string | Yes | Event type. The value is fixed at **'privateModeChange'**, indicating the event of display private mode changes.| | type | string | Yes | Event type. The value is fixed at **'privateModeChange'**, indicating the event of display privacy mode changes.|
| callback | Callback&lt;boolean&gt; | No | Callback used to return whether the privacy mode of the display is changed. The value **true** means that the display changes to the privacy mode, and **false** means the opposite.| | callback | Callback&lt;boolean&gt; | No | Callback used to return whether the privacy mode of the display is changed. The value **true** means that the display changes to the privacy mode, and **false** means the opposite.|
**Example** **Example**
...@@ -479,22 +479,22 @@ Before calling any API in **Display**, you must use [getAllDisplays()](#displayg ...@@ -479,22 +479,22 @@ Before calling any API in **Display**, you must use [getAllDisplays()](#displayg
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
| Name| Type| Readable| Writable| Description| | Name| Type| Readable| Writable| Description |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |---------------------------------------------------------------------------------------------------------------|
| id | number | Yes| No| ID of the display.| | id | number | Yes| No| ID of the display. The value must be an integer. |
| name | string | Yes| No| Name of the display.| | name | string | Yes| No| Name of the display. |
| alive | boolean | Yes| No| Whether the display is alive.| | alive | boolean | Yes| No| Whether the display is alive. |
| state | [DisplayState](#displaystate) | Yes| No| State of the display.| | state | [DisplayState](#displaystate) | Yes| No| State of the display. |
| refreshRate | number | Yes| No| Refresh rate of the display.| | refreshRate | number | Yes| No| Refresh rate of the display. The value must be an integer. |
| rotation | number | Yes| No| Screen rotation angle of the display.<br>The value **0** indicates that the screen of the display rotates by 0°.<br>The value **1** indicates that the screen of the display rotates by 90°.<br>The value **2** indicates that the screen of the display rotates by 180°.<br>The value **3** indicates that the screen of the display rotates by 270°.| | rotation | number | Yes| No| Screen rotation angle of the display.<br>The value **0** indicates that the screen of the display rotates by 0°.<br>The value **1** indicates that the screen of the display rotates by 90°.<br>The value **2** indicates that the screen of the display rotates by 180°.<br>The value **3** indicates that the screen of the display rotates by 270°.|
| width | number | Yes| No| Width of the display, in pixels.| | width | number | Yes| No| Width of the display, in pixels. The value must be an integer. |
| height | number | Yes| No| Height of the display, in pixels.| | height | number | Yes| No| Height of the display, in pixels. The value must be an integer. |
| densityDPI | number | Yes| No| Screen density of the display, that is, the number of dots per inch. Generally, the value is **160** or **480**.| | densityDPI | number | Yes| No| Screen density of the display, that is, the number of dots per inch. The value must be a floating point number. Generally, the value is **160.0** or **480.0**. |
| orientation<sup>10+</sup> | [Orientation](#orientation10) | Yes| No| Orientation of the display.| | orientation<sup>10+</sup> | [Orientation](#orientation10) | Yes| No| Orientation of the display. |
| densityPixels | number | Yes| No| Logical density of the display, which is a scaling coefficient independent of the pixel unit. Generally, the value is **1** or **3**.| | densityPixels | number | Yes| No| Logical density of the display, which is a scaling coefficient independent of the pixel unit. The value must be a floating point number. Generally, the value is **1.0** or **3.0**. |
| scaledDensity | number | Yes| No| Scaling factor for fonts displayed on the display. Generally, the value is the same as that of **densityPixels**.| | scaledDensity | number | Yes| No| Scaling factor for fonts displayed on the display. The value must be a floating point number. Generally, the value is the same as that of **densityPixels**. |
| xDPI | number | Yes| No| Exact physical dots per inch of the screen in the horizontal direction.| | xDPI | number | Yes| No| Exact physical dots per inch of the screen in the horizontal direction. The value must be a floating point number. |
| yDPI | number | Yes| No| Exact physical dots per inch of the screen in the vertical direction.| | yDPI | number | Yes| No| Exact physical dots per inch of the screen in the vertical direction. The value must be a floating point number. |
### getCutoutInfo<sup>9+</sup> ### getCutoutInfo<sup>9+</sup>
getCutoutInfo(callback: AsyncCallback&lt;CutoutInfo&gt;): void getCutoutInfo(callback: AsyncCallback&lt;CutoutInfo&gt;): void
......
...@@ -96,9 +96,9 @@ Subscribes to events related to the screen state. ...@@ -96,9 +96,9 @@ Subscribes to events related to the screen state.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------- | ---------------------- | ---- | ------------------------------------------------------------ | | --------- | ---------------------- | ---- | ----------------------------------------------------------- |
| eventType | string | Yes | Event type.<br>- **connect**: an event indicating that the screen is connected.<br>- **disconnect**: an event indicating that the screen is disconnected.<br>- **change**: an event indicating that the screen state changes.| | eventType | string | Yes | Event type.<br>- **connect**: an event indicating that the screen is connected.<br>- **disconnect**: an event indicating that the screen is disconnected.<br>- **change**: an event indicating that the screen state changes.|
| callback | Callback&lt;number&gt; | Yes | Callback used to return the screen ID. | | callback | Callback&lt;number&gt; | Yes | Callback used to return the screen ID, which is an integer. |
**Example** **Example**
...@@ -126,7 +126,7 @@ Unsubscribes from events related to the screen state. ...@@ -126,7 +126,7 @@ Unsubscribes from events related to the screen state.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------- | ---------------------- | ---- | ------------------------------------------------------------ | | --------- | ---------------------- | ---- | ------------------------------------------------------------ |
| eventType | string | Yes | Event type.<br>- **connect**: an event indicating that the screen is connected.<br>- **disconnect**: an event indicating that the screen is disconnected.<br>- **change**: an event indicating that the screen state changes.| | eventType | string | Yes | Event type.<br>- **connect**: an event indicating that the screen is connected.<br>- **disconnect**: an event indicating that the screen is disconnected.<br>- **change**: an event indicating that the screen state changes.|
| callback | Callback&lt;number&gt; | No | Callback used to return the screen ID. | | callback | Callback&lt;number&gt; | No | Callback used to return the screen ID, which is an integer. |
**Example** **Example**
...@@ -152,9 +152,9 @@ Sets the screen to the expanded mode. This API uses an asynchronous callback to ...@@ -152,9 +152,9 @@ Sets the screen to the expanded mode. This API uses an asynchronous callback to
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------ | ---- | -------------------------------- | | -------- | ------------------------------------------ | ---- |----------------------------|
| options | Array&lt;[ExpandOption](#expandoption)&gt; | Yes | Parameters for expanding the screen. | | options | Array&lt;[ExpandOption](#expandoption)&gt; | Yes | Parameters for expanding the screen. |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the group ID of the expanded screens.| | callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the group ID of the expanded screens, which is an integer.|
**Error codes** **Error codes**
...@@ -199,8 +199,8 @@ Sets the screen to the expanded mode. This API uses a promise to return the resu ...@@ -199,8 +199,8 @@ Sets the screen to the expanded mode. This API uses a promise to return the resu
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ----------------------------------- | | --------------------- |---------------------------------|
| Promise&lt;number&gt; | Promise used to return the group ID of the expanded screens.| | Promise&lt;number&gt; | Promise used to return the group ID of the expanded screens, which is an integer.|
**Error codes** **Error codes**
...@@ -234,9 +234,9 @@ Stops the expanded mode. This API uses an asynchronous callback to return the re ...@@ -234,9 +234,9 @@ Stops the expanded mode. This API uses an asynchronous callback to return the re
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description |
| ------------ | --------------------------- | --- | -------------------------------------------------------------- | | ------------ | --------------------------- | --- |-----------------------------------------|
| expandScreen | Array&lt;number&gt; | Yes | IDs of the expanded screens. | | expandScreen | Array&lt;number&gt; | Yes | IDs of the expanded screens. Each ID must be an integer. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If the expanded mode is stopped, **err** is **undefined**; otherwise, **err** is an error object.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If the expanded mode is stopped, **err** is **undefined**; otherwise, **err** is an error object.|
**Error codes** **Error codes**
...@@ -274,9 +274,9 @@ Stops the expanded mode. This API uses a promise to return the result. ...@@ -274,9 +274,9 @@ Stops the expanded mode. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description |
| ------------ | ------------------- | --- | --------------- | | ------------ | ------------------- | --- |--------------------|
| expandScreen | Array&lt;number&gt; | Yes | IDs of the expanded screens.| | expandScreen | Array&lt;number&gt; | Yes | IDs of the expanded screens. Each ID must be an integer.|
**Return value** **Return value**
...@@ -318,10 +318,10 @@ Sets screen mirroring. This API uses an asynchronous callback to return the resu ...@@ -318,10 +318,10 @@ Sets screen mirroring. This API uses an asynchronous callback to return the resu
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------------ | --------------------------- | ---- |-----------------| | ------------ | --------------------------- | ---- |--------------------|
| mainScreen | number | Yes | ID of the primary screen. | | mainScreen | number | Yes | ID of the primary screen. The value must be an integer. |
| mirrorScreen | Array&lt;number&gt; | Yes | IDs of secondary screens. | | mirrorScreen | Array&lt;number&gt; | Yes | IDs of secondary screens. Each ID must be an integer.|
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the group ID of the secondary screens.| | callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the group ID of the secondary screens, which is an integer. |
**Error codes** **Error codes**
...@@ -360,15 +360,15 @@ Sets screen mirroring. This API uses a promise to return the result. ...@@ -360,15 +360,15 @@ Sets screen mirroring. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------------ | ------------------- | ---- |-----------| | ------------ | ------------------- | ---- |--------------------|
| mainScreen | number | Yes | ID of the primary screen. | | mainScreen | number | Yes | ID of the primary screen. The value must be an integer. |
| mirrorScreen | Array&lt;number&gt; | Yes | IDs of secondary screens.| | mirrorScreen | Array&lt;number&gt; | Yes | IDs of secondary screens. Each ID must be an integer.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ----------------------------------- | | --------------------- |---------------------------------|
| Promise&lt;number&gt; | Promise used to return the group ID of the secondary screens.| | Promise&lt;number&gt; | Promise used to return the group ID of the secondary screens, which is an integer.|
**Error codes** **Error codes**
...@@ -404,10 +404,10 @@ Stops screen mirroring. This API uses an asynchronous callback to return the res ...@@ -404,10 +404,10 @@ Stops screen mirroring. This API uses an asynchronous callback to return the res
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description |
| ------------ | --------------------------- | --- | -------------------------------------------------------------- | | ------------ | --------------------------- | --- |-----------------------------------------|
| mirrorScreen | Array&lt;number&gt; | Yes | IDs of secondary screens. | | mirrorScreen | Array&lt;number&gt; | Yes | IDs of secondary screens. Each ID must be an integer. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If screen mirroring is stopped, **err** is **undefined**; otherwise, **err** is an error object. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If screen mirroring is stopped, **err** is **undefined**; otherwise, **err** is an error object.|
**Error codes** **Error codes**
...@@ -444,9 +444,9 @@ Stops screen mirroring. This API uses a promise to return the result. ...@@ -444,9 +444,9 @@ Stops screen mirroring. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description |
| ------------ | ------------------- | --- | --------------- | | ------------ | ------------------- | --- |--------------------|
| mirrorScreen | Array&lt;number&gt; | Yes | IDs of secondary screens.| | mirrorScreen | Array&lt;number&gt; | Yes | IDs of secondary screens. Each ID must be an integer.|
**Return value** **Return value**
...@@ -590,7 +590,7 @@ Destroys a virtual screen. This API uses an asynchronous callback to return the ...@@ -590,7 +590,7 @@ Destroys a virtual screen. This API uses an asynchronous callback to return the
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ------------------------------------------------------------ | | -------- | ------------------------- | ---- | ------------------------------------------------------------ |
| screenId | number | Yes | Screen ID. | | screenId | number | Yes | Screen ID. The value must be an integer. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If the virtual screen is destroyed, **err** is **undefined**; otherwise, **err** is an error object.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If the virtual screen is destroyed, **err** is **undefined**; otherwise, **err** is an error object.|
**Error codes** **Error codes**
...@@ -630,7 +630,7 @@ Destroys a virtual screen. This API uses a promise to return the result. ...@@ -630,7 +630,7 @@ Destroys a virtual screen. This API uses a promise to return the result.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ---------- | | -------- | ------ | ---- | ---------- |
| screenId | number | Yes | Screen ID.| | screenId | number | Yes | Screen ID. The value must be an integer.|
**Return value** **Return value**
...@@ -675,7 +675,7 @@ Sets the surface for a virtual screen. This API uses an asynchronous callback to ...@@ -675,7 +675,7 @@ Sets the surface for a virtual screen. This API uses an asynchronous callback to
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------- | ------------------------- | ---- | ------------------------------------------------------------ | | --------- | ------------------------- | ---- | ------------------------------------------------------------ |
| screenId | number | Yes | Screen ID. | | screenId | number | Yes | Screen ID. The value must be an integer. |
| surfaceId | string | Yes | Surface ID. | | surfaceId | string | Yes | Surface ID. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If the virtual screen surface is successfully set, **err** is **undefined**; otherwise, **err** is an error object.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If the virtual screen surface is successfully set, **err** is **undefined**; otherwise, **err** is an error object.|
...@@ -719,7 +719,7 @@ Sets the surface for a virtual screen. This API uses a promise to return the res ...@@ -719,7 +719,7 @@ Sets the surface for a virtual screen. This API uses a promise to return the res
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------- | ------ | ---- | ------------- | | --------- | ------ | ---- | ------------- |
| screenId | number | Yes | Screen ID. | | screenId | number | Yes | Screen ID. The value must be an integer. |
| surfaceId | string | Yes | Surface ID.| | surfaceId | string | Yes | Surface ID.|
**Return value** **Return value**
...@@ -877,9 +877,9 @@ Defines the parameters for expanding a screen. ...@@ -877,9 +877,9 @@ Defines the parameters for expanding a screen.
| Name | Type| Readable| Writable| Description | | Name | Type| Readable| Writable| Description |
| -------- | -------- | ---- | ---- | ------------------- | | -------- | -------- | ---- | ---- | ------------------- |
| screenId | number | Yes | Yes | Screen ID. | | screenId | number | Yes | Yes | Screen ID. The value must be an integer. |
| startX | number | Yes | Yes | Start X coordinate of the screen.| | startX | number | Yes | Yes | Start X coordinate of the screen. The value must be an integer.|
| startY | number | Yes | Yes | Start Y coordinate of the screen.| | startY | number | Yes | Yes | Start Y coordinate of the screen. The value must be an integer.|
## VirtualScreenOption ## VirtualScreenOption
...@@ -888,12 +888,12 @@ Defines virtual screen parameters. ...@@ -888,12 +888,12 @@ Defines virtual screen parameters.
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
| Name | Type| Readable| Writable| Description | | Name | Type| Readable| Writable| Description |
| --------- | -------- | ---- | ---- | ------------------------- | | --------- | -------- | ---- | ---- |--------------------------|
| name | string | Yes | Yes | Name of a virtual screen. | | name | string | Yes | Yes | Name of a virtual screen. |
| width | number | Yes | Yes | Width of the virtual screen, in pixels.| | width | number | Yes | Yes | Width of the virtual screen, in pixels. The value must be an integer.|
| height | number | Yes | Yes | Height of the virtual screen, in pixels.| | height | number | Yes | Yes | Height of the virtual screen, in pixels. The value must be an integer.|
| density | number | Yes | Yes | Density of the virtual screen. | | density | number | Yes | Yes | Density of the virtual screen. The value must be a floating point number. |
| surfaceId | string | Yes | Yes | Surface ID of the virtual screen.| | surfaceId | string | Yes | Yes | Surface ID of the virtual screen. |
## Screen ## Screen
...@@ -906,11 +906,11 @@ Before calling any API in **Screen**, you must use **[getAllScreens()](#screenge ...@@ -906,11 +906,11 @@ Before calling any API in **Screen**, you must use **[getAllScreens()](#screenge
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
| Name | Type | Readable| Writable| Description | | Name | Type | Readable| Writable| Description |
| ----------------- | ---------------------------------------------- | ---- | ---- | ---------------------- | | ----------------- | ---------------------------------------------- | ---- | ---- |-------------------------------------------------------------|
| id | number | Yes | No | Screen ID. | | id | number | Yes | No | Screen ID. The value must be an integer. |
| parent | number | Yes | No | ID of the group to which a screen belongs. | | parent | number | Yes | No | ID of the group to which a screen belongs. The value must be an integer. |
| supportedModeInfo | Array&lt;[ScreenModeInfo](#screenmodeinfo)&gt; | Yes | No | Mode set supported by the screen. | | supportedModeInfo | Array&lt;[ScreenModeInfo](#screenmodeinfo)&gt; | Yes | No | Mode set supported by the screen. |
| activeModeIndex | number | Yes | No | Index of the active screen mode. The current value and value range of this parameter vary according to the screen resolution, refresh rate, and device hardware.| | activeModeIndex | number | Yes | No | Index of the active screen mode. The current value and value range of this parameter vary according to the screen resolution, refresh rate, and device hardware. The value must be an integer.|
| orientation | [Orientation](#orientation) | Yes | No | Screen orientation. | | orientation | [Orientation](#orientation) | Yes | No | Screen orientation. |
| sourceMode<sup>10+</sup> | [ScreenSourceMode](#screensourcemode10) | Yes | No | Source mode of the screen. | | sourceMode<sup>10+</sup> | [ScreenSourceMode](#screensourcemode10) | Yes | No | Source mode of the screen. |
...@@ -1002,7 +1002,7 @@ Sets the active mode of the screen. This API uses an asynchronous callback to re ...@@ -1002,7 +1002,7 @@ Sets the active mode of the screen. This API uses an asynchronous callback to re
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------- | ------------------------- | ---- | ------------------------------------------------------------ | | --------- | ------------------------- | ---- | ------------------------------------------------------------ |
| modeIndex | number | Yes | Index of the mode to set. The current value and value range of this parameter vary according to the screen resolution, refresh rate, and device hardware.| | modeIndex | number | Yes | Index of the mode to set. The current value and value range of this parameter vary according to the screen resolution, refresh rate, and device hardware. The value must be an integer.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If the active mode is successfully set, **err** is **undefined**; otherwise, **err** is an error object.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If the active mode is successfully set, **err** is **undefined**; otherwise, **err** is an error object.|
**Error codes** **Error codes**
...@@ -1040,7 +1040,7 @@ Sets the active mode of the screen. This API uses a promise to return the result ...@@ -1040,7 +1040,7 @@ Sets the active mode of the screen. This API uses a promise to return the result
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------- | ------ | ---- | ---------- | | --------- | ------ | ---- | ---------- |
| modeIndex | number | Yes | Index of the mode to set. The current value and value range of this parameter vary according to the screen resolution, refresh rate, and device hardware.| | modeIndex | number | Yes | Index of the mode to set. The current value and value range of this parameter vary according to the screen resolution, refresh rate, and device hardware. The value must be an integer.|
**Return value** **Return value**
...@@ -1081,8 +1081,8 @@ Sets the pixel density of the screen. This API uses an asynchronous callback to ...@@ -1081,8 +1081,8 @@ Sets the pixel density of the screen. This API uses an asynchronous callback to
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ---------- | ------------------------- | ---- | ------------------------------------------------------------ | | ---------- | ------------------------- | ---- |------------------------------------------|
| densityDpi | number | Yes | Pixel density. The value ranges from 80 to 640. | | densityDpi | number | Yes | Pixel density. The value must be an integer in the range [80, 640]. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If the pixel density is successfully set, **err** is **undefined**; otherwise, **err** is an error object.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If the pixel density is successfully set, **err** is **undefined**; otherwise, **err** is an error object.|
**Error codes** **Error codes**
...@@ -1119,8 +1119,8 @@ Sets the pixel density of the screen. This API uses a promise to return the resu ...@@ -1119,8 +1119,8 @@ Sets the pixel density of the screen. This API uses a promise to return the resu
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ---------- | ------ | ---- | ---------------------------------- | | ---------- | ------ | ---- |------------------------------------|
| densityDpi | number | Yes | Pixel density. The value ranges from 80 to 640.| | densityDpi | number | Yes | Pixel density. The value must be an integer in the range [80, 640].|
**Return value** **Return value**
...@@ -1187,7 +1187,7 @@ Defines the screen mode information. ...@@ -1187,7 +1187,7 @@ Defines the screen mode information.
| Name | Type| Readable| Writable| Description | | Name | Type| Readable| Writable| Description |
| ----------- | -------- | ---- | ---- | -------------------------------------------------- | | ----------- | -------- | ---- | ---- | -------------------------------------------------- |
| id | number | Yes | Yes | Mode ID. The supported mode is determined by the device resolution and refresh rate.| | id | number | Yes | Yes | Mode ID. The supported mode is determined by the device resolution and refresh rate. The value must be an integer.|
| width | number | Yes | Yes | Width of the screen, in pixels. | | width | number | Yes | Yes | Width of the screen, in pixels. The value must be an integer. |
| height | number | Yes | Yes | Height of the screen, in pixels. | | height | number | Yes | Yes | Height of the screen, in pixels. The value must be an integer. |
| refreshRate | number | Yes | Yes | Screen refresh rate. | | refreshRate | number | Yes | Yes | Refresh rate of the screen. The value must be an integer. |
...@@ -25,8 +25,8 @@ Describes screenshot options. ...@@ -25,8 +25,8 @@ Describes screenshot options.
| ---------------------- | ------------- | ---- | ------------------------------------------------------------ | | ---------------------- | ------------- | ---- | ------------------------------------------------------------ |
| screenRect | [Rect](#rect) | No | Region of the screen to capture. If this parameter is null, the full screen will be captured. | | screenRect | [Rect](#rect) | No | Region of the screen to capture. If this parameter is null, the full screen will be captured. |
| imageSize | [Size](#size) | No | Size of the screen region to capture. If this parameter is null, the full screen will be captured. | | imageSize | [Size](#size) | No | Size of the screen region to capture. If this parameter is null, the full screen will be captured. |
| rotation | number | No | Rotation angle of the screenshot. Currently, the value can be **0** only. The default value is **0**. | | rotation | number | No | Rotation angle of the screenshot. Currently, the value can be **0** only. The default value is **0**. The value must be an integer. |
| displayId<sup>8+</sup> | number | No | ID of the [display](js-apis-display.md#display) device on which the screen region is to be captured.| | displayId<sup>8+</sup> | number | No | ID of the [display](js-apis-display.md#display) device on which the screen region is to be captured. The value must be an integer.|
## Rect ## Rect
...@@ -37,10 +37,10 @@ Describes the region of the screen to capture. ...@@ -37,10 +37,10 @@ Describes the region of the screen to capture.
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------------------------------ | | ------ | ------ | ---- | ------------------------------------------------------------ |
| left | number | Yes | Left boundary of the screen region to capture, in pixels.| | left | number | Yes | Left boundary of the screen region to capture, in pixels. The value must be an integer.|
| top | number | Yes | Top boundary of the screen region to capture, in pixels.| | top | number | Yes | Top boundary of the screen region to capture, in pixels. The value must be an integer.|
| width | number | Yes | Width of the screen region to capture, in pixels.| | width | number | Yes | Width of the screen region to capture, in pixels. The value must be an integer.|
| height | number | Yes | Height of the screen region to capture, in pixels.| | height | number | Yes | Height of the screen region to capture, in pixels. The value must be an integer.|
## Size ## Size
...@@ -51,8 +51,8 @@ Describes the size of the screen region to capture. ...@@ -51,8 +51,8 @@ Describes the size of the screen region to capture.
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------------------------------ | | ------ | ------ | ---- | ------------------------------------------------------------ |
| width | number | Yes | Width of the screen region to capture, in pixels.| | width | number | Yes | Width of the screen region to capture, in pixels. The value must be an integer.|
| height | number | Yes | Height of the screen region to capture, in pixels.| | height | number | Yes | Height of the screen region to capture, in pixels. The value must be an integer.|
## screenshot.save ## screenshot.save
......
...@@ -161,9 +161,9 @@ In the stage model: ...@@ -161,9 +161,9 @@ In the stage model:
### postMessage<sup>9+</sup> ### postMessage<sup>9+</sup>
postMessage(message: Object, transfer: ArrayBuffer[]): void; postMessage(message: Object, transfer: ArrayBuffer[]): void
Sends a message to the worker thread. The data type of the message must be sequenceable. For details about the sequenceable data types, see [More Information](#more-information). Used by the host thread to send a message to the worker thread by transferring object ownership.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
...@@ -171,8 +171,8 @@ Sends a message to the worker thread. The data type of the message must be seque ...@@ -171,8 +171,8 @@ Sends a message to the worker thread. The data type of the message must be seque
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------- | ---- | ------------------------------------------------------------ | | -------- | ------------- | ---- | ------------------------------------------------------------ |
| message | Object | Yes | Message to be sent to the worker thread. | | message | Object | Yes | Data to be sent to the worker thread. The data object must be sequenceable. For details about the supported parameter types, see [Sequenceable Data Types](#sequenceable-data-types).|
| transfer | ArrayBuffer[] | Yes | An **ArrayBuffer** object can be transferred. The value **null** should not be passed in the array.| | transfer | ArrayBuffer[] | Yes | **ArrayBuffer** instance holding an array of objects for which the ownership is transferred to the worker thread. After the transfer, the objects are available only in the worker thread. The array cannot be null.|
**Error codes** **Error codes**
...@@ -196,7 +196,7 @@ workerInstance.postMessage(buffer, [buffer]); ...@@ -196,7 +196,7 @@ workerInstance.postMessage(buffer, [buffer]);
postMessage(message: Object, options?: PostMessageOptions): void postMessage(message: Object, options?: PostMessageOptions): void
Sends a message to the worker thread. The data type of the message must be sequenceable. For details about the sequenceable data types, see [More Information](#more-information). Used by the host thread to send a message to the worker thread by transferring object ownership or copying data.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
...@@ -204,8 +204,8 @@ Sends a message to the worker thread. The data type of the message must be seque ...@@ -204,8 +204,8 @@ Sends a message to the worker thread. The data type of the message must be seque
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ----------------------------------------- | ---- | ------------------------------------------------------------ | | ------- | ----------------------------------------- | ---- | ------------------------------------------------------------ |
| message | Object | Yes | Message to be sent to the worker thread. | | message | Object | Yes | Data to be sent to the worker thread. The data object must be sequenceable. For details about the supported parameter types, see [Sequenceable Data Types](#sequenceable-data-types).|
| options | [PostMessageOptions](#postmessageoptions) | No | **ArrayBuffer** instances that can be transferred. The default value is **undefined**.| | options | [PostMessageOptions](#postmessageoptions) | No | If this parameter is specified, it functions the same as **ArrayBuffer[]**. Specifically, the ownership of the objects in the array is transferred to the worker thread and becomes unavailable in the host thread. The objects are available only in the worker thread.<br>If this parameter is not specified, the default value **undefined** is used, and information is transferred to the worker thread by copying data.|
**Error codes** **Error codes**
...@@ -617,7 +617,7 @@ workerInstance.dispatchEvent({type:"alert_once", timeStamp:0});// timeStamp is n ...@@ -617,7 +617,7 @@ workerInstance.dispatchEvent({type:"alert_once", timeStamp:0});// timeStamp is n
// The event listener created by on will not be proactively deleted. // The event listener created by on will not be proactively deleted.
workerInstance.dispatchEvent({type:"alert_on", timeStamp:0}); workerInstance.dispatchEvent({type:"alert_on", timeStamp:0});
workerInstance.dispatchEvent({type:"alert_on", timeStamp:0}); workerInstance.dispatchEvent({type:"alert_on", timeStamp:0});
// The event listener created by addEventListener will be always valid and will not be proactively deleted. // The event listener created by addEventListener will not be proactively deleted.
workerInstance.dispatchEvent({type:"alert_add", timeStamp:0}); workerInstance.dispatchEvent({type:"alert_add", timeStamp:0});
workerInstance.dispatchEvent({type:"alert_add", timeStamp:0}); workerInstance.dispatchEvent({type:"alert_add", timeStamp:0});
...@@ -792,7 +792,7 @@ workerInstance.dispatchEvent({type:"alert_once", timeStamp:0});// timeStamp is n ...@@ -792,7 +792,7 @@ workerInstance.dispatchEvent({type:"alert_once", timeStamp:0});// timeStamp is n
// The event listener created by on will not be proactively deleted. // The event listener created by on will not be proactively deleted.
workerInstance.dispatchEvent({type:"alert_on", timeStamp:0}); workerInstance.dispatchEvent({type:"alert_on", timeStamp:0});
workerInstance.dispatchEvent({type:"alert_on", timeStamp:0}); workerInstance.dispatchEvent({type:"alert_on", timeStamp:0});
// The event listener created by addEventListener will be always valid and will not be proactively deleted. // The event listener created by addEventListener will not be proactively deleted.
workerInstance.dispatchEvent({type:"alert_add", timeStamp:0}); workerInstance.dispatchEvent({type:"alert_add", timeStamp:0});
workerInstance.dispatchEvent({type:"alert_add", timeStamp:0}); workerInstance.dispatchEvent({type:"alert_add", timeStamp:0});
...@@ -849,16 +849,16 @@ Implements communication between the worker thread and the host thread. The **po ...@@ -849,16 +849,16 @@ Implements communication between the worker thread and the host thread. The **po
postMessage(messageObject: Object, transfer: ArrayBuffer[]): void; postMessage(messageObject: Object, transfer: ArrayBuffer[]): void;
Sends a message to the host thread from the worker thread. Used by the worker thread to send a message to the host thread by transferring object ownership.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------- | ---- | ------------------------------------------------------- | | -------- | ------------- | ---- | ------------------------------------------------------------ |
| message | Object | Yes | Message to be sent to the host thread. | | message | Object | Yes | Data to be sent to the host thread. The data object must be sequenceable. For details about the supported parameter types, see [Sequenceable Data Types](#sequenceable-data-types).|
| transfer | ArrayBuffer[] | Yes | An **ArrayBuffer** object can be transferred. The value **null** should not be passed in the array.| | transfer | ArrayBuffer[] | Yes | **ArrayBuffer** instance holding an array of objects for which the ownership is transferred to the host thread. After the transfer, the objects are available only in the host thread. The array cannot be null.|
**Error codes** **Error codes**
...@@ -897,7 +897,7 @@ workerPort.onmessage = function(e){ ...@@ -897,7 +897,7 @@ workerPort.onmessage = function(e){
postMessage(messageObject: Object, options?: PostMessageOptions): void postMessage(messageObject: Object, options?: PostMessageOptions): void
Sends a message to the host thread from the worker thread. Used by the worker thread to send a message to the host thread by transferring object ownership or copying data.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
...@@ -905,8 +905,8 @@ Sends a message to the host thread from the worker thread. ...@@ -905,8 +905,8 @@ Sends a message to the host thread from the worker thread.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ----------------------------------------- | ---- | ------------------------------------------------------------ | | ------- | ----------------------------------------- | ---- | ------------------------------------------------------------ |
| message | Object | Yes | Message to be sent to the host thread. | | message | Object | Yes | Data to be sent to the host thread. The data object must be sequenceable. For details about the supported parameter types, see [Sequenceable Data Types](#sequenceable-data-types).|
| options | [PostMessageOptions](#postmessageoptions) | No | **ArrayBuffer** instances that can be transferred. The default value is **undefined**.| | options | [PostMessageOptions](#postmessageoptions) | No | If this parameter is specified, it functions the same as **ArrayBuffer[]**. Specifically, the ownership of the objects in the array is transferred to the host thread and becomes unavailable in the worker thread. The objects are available only in the host thread.<br>If this parameter is not specified, the default value **undefined** is used, and information is transferred to the host thread by copying data.|
**Error codes** **Error codes**
...@@ -1256,9 +1256,9 @@ In the stage model: ...@@ -1256,9 +1256,9 @@ In the stage model:
### postMessage<sup>(deprecated)</sup> ### postMessage<sup>(deprecated)</sup>
postMessage(message: Object, transfer: ArrayBuffer[]): void; postMessage(message: Object, transfer: ArrayBuffer[]): void
Sends a message to the worker thread. The data type of the message must be sequenceable. For details about the sequenceable data types, see [More Information](#more-information). Used by the host thread to send a message to the worker thread by transferring object ownership.
> **NOTE**<br> > **NOTE**<br>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [ThreadWorker.postMessage<sup>9+</sup>](#postmessage9) instead. > This API is supported since API version 7 and deprecated since API version 9. You are advised to use [ThreadWorker.postMessage<sup>9+</sup>](#postmessage9) instead.
...@@ -1268,9 +1268,9 @@ Sends a message to the worker thread. The data type of the message must be seque ...@@ -1268,9 +1268,9 @@ Sends a message to the worker thread. The data type of the message must be seque
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------- | ---- | ----------------------------------------------- | | -------- | ------------- | ---- | ------------------------------------------------------------ |
| message | Object | Yes | Message to be sent to the worker thread. | | message | Object | Yes | Data to be sent to the worker thread. The data object must be sequenceable. For details about the supported parameter types, see [Sequenceable Data Types](#sequenceable-data-types).|
| transfer | ArrayBuffer[] | Yes | **ArrayBuffer** instances that can be transferred.| | transfer | ArrayBuffer[] | Yes | **ArrayBuffer** instance holding an array of objects for which the ownership is transferred to the worker thread. After the transfer, the objects are available only in the worker thread. The array cannot be null.|
**Example** **Example**
...@@ -1285,7 +1285,7 @@ workerInstance.postMessage(buffer, [buffer]); ...@@ -1285,7 +1285,7 @@ workerInstance.postMessage(buffer, [buffer]);
postMessage(message: Object, options?: PostMessageOptions): void postMessage(message: Object, options?: PostMessageOptions): void
Sends a message to the worker thread. The data type of the message must be sequenceable. For details about the sequenceable data types, see [More Information](#more-information). Used by the host thread to send a message to the worker thread by transferring object ownership or copying data.
> **NOTE**<br> > **NOTE**<br>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [ThreadWorker.postMessage<sup>9+</sup>](#postmessage9-1) instead. > This API is supported since API version 7 and deprecated since API version 9. You are advised to use [ThreadWorker.postMessage<sup>9+</sup>](#postmessage9-1) instead.
...@@ -1296,8 +1296,8 @@ Sends a message to the worker thread. The data type of the message must be seque ...@@ -1296,8 +1296,8 @@ Sends a message to the worker thread. The data type of the message must be seque
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ----------------------------------------- | ---- | ------------------------------------------------------------ | | ------- | ----------------------------------------- | ---- | ------------------------------------------------------------ |
| message | Object | Yes | Message to be sent to the worker thread. | | message | Object | Yes | Data to be sent to the worker thread. The data object must be sequenceable. For details about the supported parameter types, see [Sequenceable Data Types](#sequenceable-data-types).|
| options | [PostMessageOptions](#postmessageoptions) | No | **ArrayBuffer** instances that can be transferred. The default value is **undefined**.| | options | [PostMessageOptions](#postmessageoptions) | No | If this parameter is specified, it functions the same as **ArrayBuffer[]**. Specifically, the ownership of the objects in the array is transferred to the worker thread and becomes unavailable in the host thread. The objects are available only in the worker thread.<br>If this parameter is not specified, the default value **undefined** is used, and information is transferred to the worker thread by copying data.|
**Example** **Example**
...@@ -1696,7 +1696,7 @@ Implements communication between the worker thread and the host thread. The **po ...@@ -1696,7 +1696,7 @@ Implements communication between the worker thread and the host thread. The **po
postMessage(messageObject: Object, transfer: Transferable[]): void; postMessage(messageObject: Object, transfer: Transferable[]): void;
Sends a message to the host thread from the worker thread. Used by the worker thread to send a message to the host thread by transferring object ownership.
> **NOTE**<br> > **NOTE**<br>
> This API is deprecated since API version 9. You are advised to use [ThreadWorkerGlobalScope<sup>9+</sup>.postMessage<sup>9+</sup>](#postmessage9-2). > This API is deprecated since API version 9. You are advised to use [ThreadWorkerGlobalScope<sup>9+</sup>.postMessage<sup>9+</sup>](#postmessage9-2).
...@@ -1707,14 +1707,14 @@ Sends a message to the host thread from the worker thread. ...@@ -1707,14 +1707,14 @@ Sends a message to the host thread from the worker thread.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ----------------------------------------- | ---- | ------------------------------------------------------------ | | ------- | ----------------------------------------- | ---- | ------------------------------------------------------------ |
| messageObject | Object | Yes | Message to be sent to the host thread. | | messageObject | Object | Yes | Data to be sent to the host thread. The data object must be sequenceable. For details about the supported parameter types, see [Sequenceable Data Types](#sequenceable-data-types).|
| transfer| Transferable[] | Yes | Currently, this parameter is not supported. | | transfer| Transferable[] | Yes | Currently, this parameter is not supported. |
### postMessage<sup>9+</sup> ### postMessage<sup>9+</sup>
postMessage(messageObject: Object, transfer: ArrayBuffer[]): void; postMessage(messageObject: Object, transfer: ArrayBuffer[]): void;
Sends a message to the host thread from the worker thread. Used by the worker thread to send a message to the host thread by transferring object ownership.
> **NOTE** > **NOTE**
> >
...@@ -1725,9 +1725,9 @@ Sends a message to the host thread from the worker thread. ...@@ -1725,9 +1725,9 @@ Sends a message to the host thread from the worker thread.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------- | ---- | ----------------------------------------------------- | | -------- | ------------- | ---- | ------------------------------------------------------------ |
| message | Object | Yes | Message to be sent to the host thread. | | message | Object | Yes | Data to be sent to the host thread. The data object must be sequenceable. For details about the supported parameter types, see [Sequenceable Data Types](#sequenceable-data-types).|
| transfer | ArrayBuffer[] | Yes | An **ArrayBuffer** object can be transferred. The value **null** should not be passed in the array.| | transfer | ArrayBuffer[] | Yes | **ArrayBuffer** instance holding an array of objects for which the ownership is transferred to the host thread. After the transfer, the objects are available only in the host thread. The array cannot be null.|
**Example** **Example**
...@@ -1756,7 +1756,7 @@ parentPort.onmessage = function(e){ ...@@ -1756,7 +1756,7 @@ parentPort.onmessage = function(e){
postMessage(messageObject: Object, options?: PostMessageOptions): void postMessage(messageObject: Object, options?: PostMessageOptions): void
Sends a message to the host thread from the worker thread. Used by the worker thread to send a message to the host thread by transferring object ownership or copying data.
> **NOTE**<br> > **NOTE**<br>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [ThreadWorkerGlobalScope<sup>9+</sup>.postMessage<sup>9+</sup>](#postmessage9-3). > This API is supported since API version 7 and deprecated since API version 9. You are advised to use [ThreadWorkerGlobalScope<sup>9+</sup>.postMessage<sup>9+</sup>](#postmessage9-3).
...@@ -1767,8 +1767,8 @@ Sends a message to the host thread from the worker thread. ...@@ -1767,8 +1767,8 @@ Sends a message to the host thread from the worker thread.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ----------------------------------------- | ---- | ------------------------------------------------------------ | | ------- | ----------------------------------------- | ---- | ------------------------------------------------------------ |
| message | Object | Yes | Message to be sent to the host thread. | | message | Object | Yes | Data to be sent to the host thread. The data object must be sequenceable. For details about the supported parameter types, see [Sequenceable Data Types](#sequenceable-data-types).|
| options | [PostMessageOptions](#postmessageoptions) | No | **ArrayBuffer** instances that can be transferred. The default value is **undefined**.| | options | [PostMessageOptions](#postmessageoptions) | No | If this parameter is specified, it functions the same as **ArrayBuffer[]**. Specifically, the ownership of the objects in the array is transferred to the host thread and becomes unavailable in the worker thread. The objects are available only in the host thread.<br>If this parameter is not specified, the default value **undefined** is used, and information is transferred to the host thread by copying data.|
**Example** **Example**
...@@ -1893,7 +1893,7 @@ parentPort.onmessageerror = function(e) { ...@@ -1893,7 +1893,7 @@ parentPort.onmessageerror = function(e) {
## PostMessageOptions ## PostMessageOptions
Specifies the object whose ownership needs to be transferred during data transfer. The object must be **ArrayBuffer**. Defines the object for which the ownership is to be transferred during data transfer. The object must be an **ArrayBuffer** instance. After the ownership is transferred, the object becomes unavailable in the sender and can be used only in the receiver.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
...@@ -2091,19 +2091,20 @@ workerPort.onerror = function(e) { ...@@ -2091,19 +2091,20 @@ workerPort.onerror = function(e) {
``` ```
### Memory Model ### Memory Model
The worker thread is implemented based on the actor model. In the worker interaction process, the JS main thread can create multiple worker threads, each of which are isolated and transfer data through sequentialization. They complete computing tasks and return the result to the main thread. The worker thread is implemented based on the actor model. In the worker interaction process, the JS main thread can create multiple worker threads, each of which are isolated and transfer data through serialization. They complete computing tasks and return the result to the main thread.
Each actor concurrently processes tasks of the main thread. For each actor, there is a message queue and a single-thread execution module. The message queue receives requests from the main thread and other actors; the single-thread execution module serially processes requests, sends requests to other actors, and creates new actors. These isolated actors use the asynchronous mode and can run concurrently. Each actor concurrently processes tasks of the main thread. For each actor, there is a message queue and a single-thread execution module. The message queue receives requests from the main thread and other actors; the single-thread execution module serially processes requests, sends requests to other actors, and creates new actors. These isolated actors use the asynchronous mode and can run concurrently.
### Precautions ### Precautions
- Currently, a maximum of seven workers can co-exist. - Currently, a maximum of eight workers can co-exist.
- In API version 8 and earlier versions, when the number of **Worker** instances exceeds the upper limit, the error "Too many workers, the number of workers exceeds the maximum." is thrown. - In API version 8 and earlier versions, when the number of **Worker** instances exceeds the upper limit, the error "Too many workers, the number of workers exceeds the maximum." is thrown.
- Since API version 9, when the number of **Worker** instances exceeds the upper limit, the business error "Worker initialization failure, the number of workers exceeds the maximum" is thrown. - Since API version 9, when the number of **Worker** instances exceeds the upper limit, the business error "Worker initialization failure, the number of workers exceeds the maximum." is thrown.
- To proactively destroy a worker thread, you can call **terminate()** or **parentPort.close()** of the newly created **Worker** instance. - To proactively destroy a worker thread, you can call **terminate()** or **parentPort.close()** of the newly created **Worker** instance.
- Since API version 9, if a **Worker** instance in a non-running state (such as destroyed or being destroyed) calls an API, a business error is thrown. - Since API version 9, if a **Worker** instance in a non-running state (such as destroyed or being destroyed) calls an API, a business error is thrown.
- Creating and terminating worker threads consume performance. Therefore, you are advised to manage available workers and reuse them. - Creating and terminating worker threads consume performance. Therefore, you are advised to manage available workers and reuse them.
- Do not use both **new worker.Worker** and **new worker.ThreadWorker** to create a **Worker** project. Otherwise, **Worker** functions abnormally. Since API version 9, you are advised to use [new worker.ThreadWorker](#constructor9). In API version 8 and earlier versions, you are advised to use [new worker.Worker](#constructordeprecated). - Do not use both **new worker.Worker** and **new worker.ThreadWorker** to create a **Worker** project. Otherwise, **Worker** functions abnormally. Since API version 9, you are advised to use [new worker.ThreadWorker](#constructor9). In API version 8 and earlier versions, you are advised to use [new worker.Worker](#constructordeprecated).
- When creating a **Worker** project, do not import any UI construction method (such as .ets file) to the worker thread file (for example, **worker.ts** used in this document). Otherwise, the worker module becomes invalid. To check whether any UI construction method has been imported, decompress the generated HAP file, find **worker.js** in the directory where the worker thread is created, and search for the keyword **View** globally. If the keyword exists, a UI construction method has been packaged in **worker.js**. If this is your case, change the directory level of **src** in the statement **import "xxx" from src** in the worker thread file. - When creating a **Worker** project, do not import any UI construction method (such as .ets file) to the worker thread file (for example, **worker.ts** used in this document). Otherwise, the worker module becomes invalid. To check whether any UI construction method has been imported, decompress the generated HAP file, find **worker.js** in the directory where the worker thread is created, and search for the keyword **View** globally. If the keyword exists, a UI construction method has been packaged in **worker.js**. If this is your case, change the directory level of **src** in the statement **import "xxx" from src** in the worker thread file.
- A maximum of 16 MB data can be transferred during inter-thread communication.
## Sample Code ## Sample Code
> **NOTE**<br> > **NOTE**<br>
......
...@@ -236,7 +236,7 @@ Decompresses a file. This API uses an asynchronous callback to return the result ...@@ -236,7 +236,7 @@ Decompresses a file. This API uses an asynchronous callback to return the result
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ----------------------- | ------------------- | ---- | ------------------------------------------------------------ | | ----------------------- | ------------------- | ---- | ------------------------------------------------------------ |
| inFile | string | Yes | Path of the file to decompress. The path must be an application sandbox path, which can be obtained from the context. For details about the context, see [FA Model](js-apis-inner-app-context.md) and [Stage Model](js-apis-inner-application-context.md).| | inFile | string | Yes | Path of the file to decompress. The path must be an application sandbox path, which can be obtained from the context. For details about the context, see [FA Model](js-apis-inner-app-context.md) and [Stage Model](js-apis-inner-application-context.md).|
| outFile | string | Yes | Path of the decompressed file. The path must exist in the system. Otherwise, the decompression fails. The path must be an application sandbox path, which can be obtained from the context. For details about the context, see [FA Model](js-apis-inner-app-context.md) and [Stage Model](js-apis-inner-application-context.md).| | outFile | string | Yes | Path of the decompressed file. The path must exist in the system. Otherwise, the decompression fails. The path must be an application sandbox path, which can be obtained from the context. For details about the context, see [FA Model](js-apis-inner-app-context.md) and [Stage Model](js-apis-inner-application-context.md). If a file or folder with the same name already exists in the path, they will be overwritten.|
| options | [Options](#options) | Yes | Decompression parameters. | | options | [Options](#options) | Yes | Decompression parameters. |
| AsyncCallback<**void**> | callback | No | Callback used to return the result. If the operation is successful, **null** is returned; otherwise, a specific error code is returned. | | AsyncCallback<**void**> | callback | No | Callback used to return the result. If the operation is successful, **null** is returned; otherwise, a specific error code is returned. |
...@@ -258,9 +258,7 @@ import zlib from '@ohos.zlib'; ...@@ -258,9 +258,7 @@ import zlib from '@ohos.zlib';
let inFile = '/xx/xxx.zip'; let inFile = '/xx/xxx.zip';
let outFileDir = '/xxx'; let outFileDir = '/xxx';
let options = { let options = {
level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION, level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION
memLevel: zlib.MemLevel.MEM_LEVEL_DEFAULT,
strategy: zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY
}; };
try { try {
...@@ -287,7 +285,7 @@ Decompresses a file. This API uses a promise to return the result. ...@@ -287,7 +285,7 @@ Decompresses a file. This API uses a promise to return the result.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ------------------- | ---- | ------------------------------------------------------------ | | ------- | ------------------- | ---- | ------------------------------------------------------------ |
| inFile | string | Yes | Path of the file to decompress. The path must be an application sandbox path, which can be obtained from the context. For details about the context, see [FA Model](js-apis-inner-app-context.md) and [Stage Model](js-apis-inner-application-context.md).| | inFile | string | Yes | Path of the file to decompress. The path must be an application sandbox path, which can be obtained from the context. For details about the context, see [FA Model](js-apis-inner-app-context.md) and [Stage Model](js-apis-inner-application-context.md).|
| outFile | string | Yes | Path of the decompressed file. The path must exist in the system. Otherwise, the decompression fails. The path must be an application sandbox path, which can be obtained from the context. For details about the context, see [FA Model](js-apis-inner-app-context.md) and [Stage Model](js-apis-inner-application-context.md).| | outFile | string | Yes | Path of the decompressed file. The path must exist in the system. Otherwise, the decompression fails. The path must be an application sandbox path, which can be obtained from the context. For details about the context, see [FA Model](js-apis-inner-app-context.md) and [Stage Model](js-apis-inner-application-context.md). If a file or folder with the same name already exists in the path, they will be overwritten.|
| options | [Options](#options) | Yes | Decompression parameters. | | options | [Options](#options) | Yes | Decompression parameters. |
**Error codes** **Error codes**
...@@ -306,9 +304,7 @@ import zlib from '@ohos.zlib'; ...@@ -306,9 +304,7 @@ import zlib from '@ohos.zlib';
let inFile = '/xx/xxx.zip'; let inFile = '/xx/xxx.zip';
let outFileDir = '/xxx'; let outFileDir = '/xxx';
let options = { let options = {
level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION, level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION
memLevel: zlib.MemLevel.MEM_LEVEL_DEFAULT,
strategy: zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY
}; };
try { try {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册