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

update docs against 7689+7982+8483+8902

Signed-off-by: wusongqing<wusongqing@huawei.com>
上级 a3104368
...@@ -28,29 +28,42 @@ Enumerates the display states. ...@@ -28,29 +28,42 @@ Enumerates the display states.
| STATE_VR | 5 | The display is in VR mode.| | STATE_VR | 5 | The display is in VR mode.|
| STATE_ON_SUSPEND | 6 | The display is powered on, and the CPU is suspended.| | STATE_ON_SUSPEND | 6 | The display is powered on, and the CPU is suspended.|
## Rect<sup>9+</sup>
## Display Describes a rectangle on the display.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
Describes the attributes of a display. | Name | Type| Readable| Writable| Description |
| ------ | -------- | ---- | ---- | ------------------ |
| left | number | Yes | Yes | Left boundary of the rectangle.|
| top | number | Yes | Yes | Top boundary of the rectangle.|
| width | number | Yes | Yes | Width of the rectangle. |
| height | number | Yes | Yes | Height of the rectangle. |
## WaterfallDisplayAreaRects<sup>9+</sup>
Describes the curved area (an area that is not intended for displaying content) on the waterfall display.
**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.| | left | [Rect](#rect9) | Yes | No | Bounding rectangle for the curved area, which is located on the left of the display surface.|
| name | string | Yes| No| Name of the display.| | top | [Rect](#rect9) | Yes | No | Bounding rectangle for the curved area, which is located at the top of the display surface.|
| alive | boolean | Yes| No| Whether the display is alive.| | right | [Rect](#rect9) | Yes | No | Bounding rectangle for the curved area, which is located on the right of the display surface.|
| state | [DisplayState](#displaystate) | Yes| No| State of the display.| | bottom | [Rect](#rect9) | Yes | No | Bounding rectangle for the curved area, which is located at the bottom of the display surface.|
| refreshRate | number | Yes| No| Refresh rate of the display.|
| rotation | number | Yes| No| Screen rotation angle of the display.| ## CutoutInfo<sup>9+</sup>
| width | number | Yes| No| Width of the display, in pixels.|
| height | number | Yes| No| Height of the display, in pixels.| Describes the cutout, which is an area that is not intended for displaying content on the display.
| densityDPI | number | Yes| No| Screen density of the display, in DPI.|
| densityPixels | number | Yes| No| Screen density of the display, in pixels.|
| scaledDensity | number | Yes| No| Scaling factor for fonts displayed on the display.|
| xDPI | number | Yes| No| Exact physical dots per inch of the screen in the horizontal direction.|
| yDPI | number | Yes| No| Exact physical dots per inch of the screen in the vertical direction.|
**System capability**: SystemCapability.WindowManager.WindowManager.Core
| Name | Type | Readable| Writable| Description |
| --------------------------- | ------------- | ---- | ---- | ------------------ |
| boundingRects | Array\<[Rect](#rect9)> | Yes | No | Bounding rectangle for punch holes and notches.|
| waterfallDisplayAreaRects | [WaterfallDisplayAreaRects](#waterfalldisplayarearects9) | Yes| No| Curved area on the waterfall display.|
## display.getDefaultDisplay ## display.getDefaultDisplay
...@@ -61,22 +74,24 @@ Obtains the default display object. This API uses an asynchronous callback to re ...@@ -61,22 +74,24 @@ Obtains the default display object. This API uses an asynchronous callback to re
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;[Display](#display)&gt; | Yes| Callback used to return the default display object.| | callback | AsyncCallback&lt;[Display](#display)&gt; | Yes| Callback used to return the default display object.|
**Example** **Example**
```js
var displayClass = null; ```js
display.getDefaultDisplay((err, data) => { var displayClass = null;
if (err.code) { display.getDefaultDisplay((err, data) => {
console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(err)); if (err.code) {
return; console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(err));
} return;
console.info('Succeeded in obtaining the default display object. Data:' + JSON.stringify(data)); }
displayClass = data; console.info('Succeeded in obtaining the default display object. Data:' + JSON.stringify(data));
}); displayClass = data;
``` });
```
## display.getDefaultDisplay ## display.getDefaultDisplay
...@@ -94,14 +109,16 @@ Obtains the default display object. This API uses a promise to return the result ...@@ -94,14 +109,16 @@ Obtains the default display object. This API uses a promise to return the result
**Example** **Example**
```js ```js
let promise = display.getDefaultDisplay(); var displayClass = null;
promise.then(() => { let promise = display.getDefaultDisplay();
console.log('getDefaultDisplay success'); promise.then((data) => {
}).catch((err) => { displayClass = data;
console.log('getDefaultDisplay fail: ' + JSON.stringify(err)); console.info('Succeeded in obtaining the default display object. Data:' + JSON.stringify(data));
}); }).catch((err) => {
``` console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(err));
});
```
## display.getDefaultDisplaySync<sup>9+</sup> ## display.getDefaultDisplaySync<sup>9+</sup>
...@@ -139,15 +156,15 @@ Obtains all display objects. This API uses an asynchronous callback to return th ...@@ -139,15 +156,15 @@ Obtains all display objects. This API uses an asynchronous callback to return th
**Example** **Example**
```js ```js
display.getAllDisplay((err, data) => { display.getAllDisplay((err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to obtain all the display objects. Code: ' + JSON.stringify(err)); console.error('Failed to obtain all the display objects. Code: ' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in obtaining all the display objects. Data: ' + JSON.stringify(data)) console.info('Succeeded in obtaining all the display objects. Data: ' + JSON.stringify(data));
}); });
``` ```
## display.getAllDisplay ## display.getAllDisplay
...@@ -165,22 +182,22 @@ Obtains all display objects. This API uses a promise to return the result. ...@@ -165,22 +182,22 @@ Obtains all display objects. This API uses a promise to return the result.
**Example** **Example**
```js ```js
let promise = display.getAllDisplay(); let promise = display.getAllDisplay();
promise.then(() => { promise.then((data) => {
console.log('getAllDisplay success'); console.info('Succeeded in obtaining all the display objects. Data: ' + JSON.stringify(data));
}).catch((err) => { }).catch((err) => {
console.log('getAllDisplay fail: ' + JSON.stringify(err)); console.error('Failed to obtain all the display objects. Code: ' + JSON.stringify(err));
}); });
``` ```
## display.hasPrivateWindow<sup>9+</sup> ## display.hasPrivateWindow<sup>9+</sup>
hasPrivateWindow(displayId: number): boolean hasPrivateWindow(displayId: number): boolean
Checks whether there is a visible privacy window on a display. The privacy window can be set by calling **[setPrivacyMode](js-apis-window.md#setprivacymode7)**. The content in the privacy window cannot be captured or recorded. Checks whether there is a visible privacy window on a display. The privacy window can be set by calling `[setPrivacyMode](js-apis-window.md#setprivacymode7)`. The content in the privacy window cannot be captured or recorded.
This is a system API. **System API**: This is a system API.
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
...@@ -194,21 +211,31 @@ This is a system API. ...@@ -194,21 +211,31 @@ This is a system API.
| Type | Description | | Type | Description |
| -------------------------------- |-----------------------------------------------------------------------| | -------------------------------- |-----------------------------------------------------------------------|
|boolean | Whether there is a visible privacy window on the display.<br>The value **true** means that there is a visible privacy window on the display, and **false** means the opposite.<br>| |boolean | Whether there is a visible privacy window on the display.<br>The value `true` means that there is a visible privacy window on the display, and `false` means the opposite.<br>|
**Example** **Example**
```js ```js
var ret = display.hasPrivateWindow(displayClass.id); var displayClass = null;
if (ret == undefined) { display.getDefaultDisplay((err, data) => {
console.log("HasPrivateWindow undefined."); if (err.code) {
} console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(err));
if (ret) { return;
console.log("HasPrivateWindow.");
} else if (!ret) {
console.log("Don't HasPrivateWindow.");
} }
``` console.info('Succeeded in obtaining the default display object. Data:' + JSON.stringify(data));
displayClass = data;
});
var ret = display.hasPrivateWindow(displayClass.id);
if (ret == undefined) {
console.log("Failed to check has privateWindow or not.");
}
if (ret) {
console.log("There has privateWindow.");
} else if (!ret) {
console.log("There has no privateWindow.");
}
```
## display.on('add'|'remove'|'change') ## display.on('add'|'remove'|'change')
...@@ -219,19 +246,20 @@ Subscribes to display changes. ...@@ -219,19 +246,20 @@ Subscribes to display changes.
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Event type.<br>- **add**, indicating the display addition event.<br>- **remove**, indicating the display removal event.<br>- **change**, indicating the display change event.| | type | string | Yes| Event type.<br>- **add**, indicating the display addition event.<br>- **remove**, indicating the display removal event.<br>- **change**, indicating the display change event.|
| 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.|
**Example** **Example**
```js
var callback = (data) => {
console.info('Listening enabled. Data: ' + JSON.stringify(data))
}
display.on("add", callback);
```
```js
var callback = (data) => {
console.info('Listening enabled. Data: ' + JSON.stringify(data))
}
display.on("add", callback);
```
## display.off('add'|'remove'|'change') ## display.off('add'|'remove'|'change')
...@@ -242,12 +270,81 @@ Unsubscribes from display changes. ...@@ -242,12 +270,81 @@ Unsubscribes from display changes.
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Event type.<br>- **add**, indicating the display addition event.<br>- **remove**, indicating the display removal event.<br>- **change**, indicating the display change event.| | type | string | Yes| Event type.<br>- **add**, indicating the display addition event.<br>- **remove**, indicating the display removal event.<br>- **change**, indicating the display change event.|
| 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.|
**Example** **Example**
```js
display.off("remove"); ```js
``` display.off("remove");
```
## Display
Implements a `Display` instance, with properties and APIs defined.
To call an API in the following API examples, you must first use `[getAllDisplay()](#displaygetalldisplay)`, `[getDefaultDisplay()](#displaygetdefaultdisplay)`, or `[getDefaultDisplaySync()](#displaygetdefaultdisplaysync)` to obtain a `Display` instance.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| id | number | Yes| No| ID of the display.|
| name | string | Yes| No| Name of the display.|
| alive | boolean | Yes| No| Whether the display is alive.|
| state | [DisplayState](#displaystate) | Yes| No| State of the display.|
| refreshRate | number | Yes| No| Refresh rate of the display.|
| rotation | number | Yes| No| Screen rotation angle of the display.|
| width | number | Yes| No| Width of the display, in pixels.|
| height | number | Yes| No| Height of the display, in pixels.|
| densityDPI | number | Yes| No| Screen density of the display, in DPI.|
| densityPixels | number | Yes| No| Screen density of the display, in pixels.|
| scaledDensity | number | Yes| No| Scaling factor for fonts displayed on the display.|
| xDPI | number | Yes| No| Exact physical dots per inch of the screen in the horizontal direction.|
| yDPI | number | Yes| No| Exact physical dots per inch of the screen in the vertical direction.|
### getCutoutInfo<sup>9+</sup>
getCutoutInfo(callback: AsyncCallback&lt;CutoutInfo&gt;): void
Obtains the cutout information of the display. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
| Name | Type | Mandatory| Description |
| ----------- | --------------------------- | ---- | ------------------------------------------------------------ |
| callback | AsyncCallback&lt;[CutoutInfo](#cutoutinfo9)&gt; | Yes | Callback used to If the operation is successful, `err` is `undefined` and `data` is the `CutoutInfo` object obtained. Otherwise, `err` is an error object.|
**Example**
```js
displayClass.getCutoutInfo((err, data) => {
if (err.code) {
console.error('Failed to get cutoutInfo. Cause: ' + JSON.stringify(err));
return;
}
console.info('Succeeded in getting cutoutInfo. data: ' + JSON.stringify(data));
})
```
### getCutoutInfo<sup>9+</sup>
getCutoutInfo(): Promise&lt;CutoutInfo&gt;
Obtains the cutout information of the display. This API uses a promise to return the result.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Return value**
| Type | Description |
| ------------------- | ------------------------- |
| Promise&lt;[CutoutInfo](#cutoutinfo9)&gt; | Promise used to return the `CutoutInfo` object.|
**Example**
```js
let promise = displayClass.getCutoutInfo();
promise.then((data) => {
console.info('Succeeded in getting cutoutInfo. Data: ' + JSON.stringify(data));
});
```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册