1# @ohos.display (Display) 2 3The **Display** module provides APIs for managing displays, such as obtaining information about the default display, obtaining information about all displays, and listening for the addition and removal of displays. 4 5> **NOTE** 6> 7> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. 8 9## Modules to Import 10 11```ts 12import display from '@ohos.display'; 13``` 14 15## DisplayState 16 17Enumerates the display states. 18 19**System capability**: SystemCapability.WindowManager.WindowManager.Core 20 21| Name| Value| Description| 22| -------- | -------- | -------- | 23| STATE_UNKNOWN | 0 | Unknown.| 24| STATE_OFF | 1 | The display is shut down.| 25| STATE_ON | 2 | The display is powered on.| 26| STATE_DOZE | 3 | The display is in sleep mode.| 27| STATE_DOZE_SUSPEND | 4 | The display is in sleep mode, and the CPU is suspended.| 28| STATE_VR | 5 | The display is in VR mode.| 29| STATE_ON_SUSPEND | 6 | The display is powered on, and the CPU is suspended.| 30 31## Orientation<sup>10+</sup> 32 33Enumerates the orientations of the display. 34 35**System capability**: SystemCapability.WindowManager.WindowManager.Core 36 37| Name| Value| Description| 38| -------- | -------- | -------- | 39| PORTRAIT | 0 | The display is in portrait mode.| 40| LANDSCAPE | 1 | The display is in landscape mode.| 41| PORTRAIT_INVERTED | 2 | The display is in reverse portrait mode.| 42| LANDSCAPE_INVERTED | 3 | The display is in reverse landscape mode.| 43 44## FoldStatus<sup>10+</sup> 45 46Enumerates the folding statuses of a foldable device. 47 48**System capability**: SystemCapability.Window.SessionManager 49 50| Name| Value| Description| 51| -------- | -------- | -------- | 52| FOLD_STATUS_UNKNOWN | 0 | The folding status of the device is unknown.| 53| FOLD_STATUS_EXPANDED | 1 | The device is fully open.| 54| FOLD_STATUS_FOLDED | 2 | The device is folded (completely closed).| 55| FOLD_STATUS_HALF_FOLDED | 3 | The device is half-folded, somehow between fully open and completely closed.| 56 57## FoldDisplayMode<sup>10+</sup> 58 59Enumerates the display modes of a foldable device. 60 61**System capability**: SystemCapability.Window.SessionManager 62 63| Name| Value| Description| 64| -------- | -------- | -------- | 65| FOLD_DISPLAY_MODE_UNKNOWN | 0 | The display mode of the device is unknown.| 66| FOLD_DISPLAY_MODE_FULL | 1 | The device is displayed in full screen.| 67| FOLD_DISPLAY_MODE_MAIN | 2 | The main screen of the device is displayed.| 68| FOLD_DISPLAY_MODE_SUB | 3 | The subscreen of the device is displayed.| 69| FOLD_DISPLAY_MODE_COORDINATION | 4 | Both screens of the device are displayed in collaborative mode.| 70 71## FoldCreaseRegion<sup>10+</sup> 72 73Defines the crease region of a foldable device. 74 75**System capability**: SystemCapability.Window.SessionManager 76 77| Name | Type| Readable| Writable| Description | 78| ------ | -------- | ---- | ---- | ------------------ | 79| displayId | number | Yes | No | ID of the screen where the crease is located.| 80| creaseRects | Array\<[Rect](#rect9)> | Yes | No | Crease region.| 81 82## Rect<sup>9+</sup> 83 84Describes a rectangle on the display. 85 86**System capability**: SystemCapability.WindowManager.WindowManager.Core 87 88| Name | Type| Readable| Writable| Description | 89| ------ | -------- | ---- | ---- | ------------------ | 90| left | number | Yes | Yes | Left boundary of the rectangle, in px. The value must be an integer.| 91| top | number | Yes | Yes | Top boundary of the rectangle, in px. The value must be an integer.| 92| width | number | Yes | Yes | Width of the rectangle, in px. The value must be an integer. | 93| height | number | Yes | Yes | Height of the rectangle, in px. The value must be an integer. | 94 95## WaterfallDisplayAreaRects<sup>9+</sup> 96 97Describes the curved area (an area that is not intended for displaying content) on the waterfall display. 98 99**System capability**: SystemCapability.WindowManager.WindowManager.Core 100 101| Name | Type | Readable| Writable| Description | 102| ------ | ------------- | ---- | ---- | ------------------ | 103| left | [Rect](#rect9) | Yes | No | Bounding rectangle for the curved area, which is located on the left of the display surface.| 104| top | [Rect](#rect9) | Yes | No | Bounding rectangle for the curved area, which is located at the top of the display surface.| 105| right | [Rect](#rect9) | Yes | No | Bounding rectangle for the curved area, which is located on the right of the display surface.| 106| bottom | [Rect](#rect9) | Yes | No | Bounding rectangle for the curved area, which is located at the bottom of the display surface.| 107 108## CutoutInfo<sup>9+</sup> 109 110Describes the cutout, which is an area that is not intended for displaying content on the display. 111 112**System capability**: SystemCapability.WindowManager.WindowManager.Core 113 114| Name | Type | Readable| Writable| Description | 115| --------------------------- | ------------- | ---- | ---- | ------------------ | 116| boundingRects | Array\<[Rect](#rect9)> | Yes | No | Bounding rectangle for punch holes and notches.| 117| waterfallDisplayAreaRects | [WaterfallDisplayAreaRects](#waterfalldisplayarearects9) | Yes| No| Curved area on the waterfall display.| 118 119## display.getDefaultDisplaySync<sup>9+</sup> 120 121getDefaultDisplaySync(): Display 122 123Obtains the default display object. This API returns the result synchronously. 124 125**System capability**: SystemCapability.WindowManager.WindowManager.Core 126 127**Return value** 128 129| Type | Description | 130| ------------------------------| ----------------------------------------------| 131| [Display](#display) | Default display object.| 132 133**Error codes** 134 135For details about the error codes, see [Display Error Codes](errorcode-display.md). 136 137| ID| Error Message| 138| ------- | ----------------------- | 139| 1400001 | Invalid display or screen. | 140 141**Example** 142 143```ts 144import display from '@ohos.display'; 145 146let displayClass: display.Display | null = null; 147try { 148 displayClass = display.getDefaultDisplaySync(); 149} catch (exception) { 150 console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception)); 151} 152``` 153 154## display.getAllDisplays<sup>9+</sup> 155 156getAllDisplays(callback: AsyncCallback<Array<Display>>): void 157 158Obtains all display objects. This API uses an asynchronous callback to return the result. 159 160**System capability**: SystemCapability.WindowManager.WindowManager.Core 161 162**Parameters** 163 164| Name| Type| Mandatory| Description| 165| -------- | ---------------------------------------------------- | ---- | ------------------------------- | 166| callback | AsyncCallback<Array<[Display](#display)>> | Yes| Callback used to return all the display objects.| 167 168**Error codes** 169 170For details about the error codes, see [Display Error Codes](errorcode-display.md). 171 172| ID| Error Message| 173| ------- | ----------------------- | 174| 1400001 | Invalid display or screen. | 175 176**Example** 177 178```ts 179import { BusinessError } from '@ohos.base'; 180import display from '@ohos.display'; 181 182let displayClass: Array<display.Display> = []; 183display.getAllDisplays((err: BusinessError, data: Array<display.Display>) => { 184 displayClass = data; 185 const errCode: number = err.code; 186 if (errCode) { 187 console.error('Failed to obtain all the display objects. Code: ' + JSON.stringify(err)); 188 return; 189 } 190 console.info('Succeeded in obtaining all the display objects. Data: ' + JSON.stringify(data)); 191}); 192``` 193 194## display.getAllDisplays<sup>9+</sup> 195 196getAllDisplays(): Promise<Array<Display>> 197 198Obtains all display objects. This API uses a promise to return the result. 199 200**System capability**: SystemCapability.WindowManager.WindowManager.Core 201 202**Return value** 203 204| Type| Description| 205| ----------------------------------------------- | ------------------------------------------------------- | 206| Promise<Array<[Display](#display)>> | Promise used to return all the display objects.| 207 208**Error codes** 209 210For details about the error codes, see [Display Error Codes](errorcode-display.md). 211 212| ID| Error Message| 213| ------- | ----------------------- | 214| 1400001 | Invalid display or screen. | 215 216**Example** 217 218```ts 219import { BusinessError } from '@ohos.base'; 220import display from '@ohos.display'; 221 222let displayClass: Array<display.Display> =[]; 223let promise: Promise<Array<display.Display>> = display.getAllDisplays(); 224promise.then((data: Array<display.Display>) => { 225 displayClass = data; 226 console.info('Succeeded in obtaining all the display objects. Data: ' + JSON.stringify(data)); 227}).catch((err: BusinessError) => { 228 console.error('Failed to obtain all the display objects. Code: ' + JSON.stringify(err)); 229}); 230``` 231 232## display.on('add'|'remove'|'change') 233 234on(type: 'add'|'remove'|'change', callback: Callback<number>): void 235 236Subscribes to display changes. 237 238**System capability**: SystemCapability.WindowManager.WindowManager.Core 239 240**Parameters** 241 242| Name| Type| Mandatory| Description | 243| -------- | -------- | -------- |---------------------------------------------------------------------------------------------------------------------------------| 244| 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.| 245| callback | Callback<number> | Yes| Callback used to return the ID of the display, which is an integer. | 246 247**Example** 248 249```ts 250import { Callback } from '@ohos.base'; 251 252let callback: Callback<number> = (data: number) => { 253 console.info('Listening enabled. Data: ' + JSON.stringify(data)); 254}; 255try { 256 display.on("add", callback); 257} catch (exception) { 258 console.error('Failed to register callback. Code: ' + JSON.stringify(exception)); 259} 260``` 261 262## display.off('add'|'remove'|'change') 263 264off(type: 'add'|'remove'|'change', callback?: Callback<number>): void 265 266Unsubscribes from display changes. 267 268**System capability**: SystemCapability.WindowManager.WindowManager.Core 269 270**Parameters** 271 272| Name| Type| Mandatory| Description| 273| -------- | -------- | -------- | -------- | 274| 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.| 275| callback | Callback<number> | No| Callback used for unsubscription. If this parameter is not specified, all callbacks of the current type will be unregistered.| 276 277**Example** 278 279```ts 280try { 281 display.off("remove"); 282} catch (exception) { 283 console.error('Failed to unregister callback. Code: ' + JSON.stringify(exception)); 284} 285``` 286 287## display.isFoldable<sup>10+</sup> 288isFoldable(): boolean 289 290Checks whether the device is foldable. 291 292**System capability**: SystemCapability.Window.SessionManager 293 294**Return value** 295 296| Type| Description| 297| ----------------------------------------------- | ------------------------------------------------------- | 298| boolean | Returns **true** if the device is foldable, and returns **false** otherwise.| 299 300**Error codes** 301 302For details about the error codes, see [Display Error Codes](errorcode-display.md). 303 304| ID| Error Message| 305| ------- | ----------------------- | 306| 1400003 | This display manager service works abnormally. | 307 308**Example** 309 310```ts 311import display from '@ohos.display'; 312 313let displayClass: display.Display | null = null; 314try { 315 displayClass = display.getDefaultDisplaySync(); 316 317 let ret: boolean = false; 318 try { 319 ret = display.isFoldable(); 320 } catch (exception) { 321 console.error('Failed to check is foldable or not. Code: ' + JSON.stringify(exception)); 322 } 323 if (ret == undefined) { 324 console.log("Failed to check is foldable or not."); 325 } 326 if (ret) { 327 console.log("The device is foldable."); 328 } else if (!ret) { 329 console.log("The device is not foldable."); 330 } 331} catch (exception) { 332 console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception)); 333} 334``` 335 336## display.getFoldStatus<sup>10+</sup> 337getFoldStatus(): FoldStatus 338 339Obtains the folding status of the foldable device. 340 341**System capability**: SystemCapability.Window.SessionManager 342 343**Return value** 344 345| Type| Description| 346| ----------------------------------------------- | ------------------------------------------------------- | 347| [FoldStatus](#foldstatus10) | Folding status of the device.| 348 349**Error codes** 350 351For details about the error codes, see [Display Error Codes](errorcode-display.md). 352 353| ID| Error Message| 354| ------- | ----------------------- | 355| 1400003 | This display manager service works abnormally. | 356 357**Example** 358 359```ts 360import display from '@ohos.display'; 361 362try { 363 display.getFoldStatus(); 364} catch (exception) { 365 console.error('Failed to obtain the fold status. Code: ' + JSON.stringify(exception)); 366} 367``` 368 369## display.getFoldDisplayMode<sup>10+</sup> 370getFoldDisplayMode(): FoldDisplayMode 371 372Obtains the display mode of the foldable device. 373 374**System capability**: SystemCapability.Window.SessionManager 375 376**Return value** 377 378| Type| Description| 379| ----------------------------------------------- | ------------------------------------------------------- | 380| [FoldDisplayMode](#folddisplaymode10) | Display mode of the device.| 381 382**Error codes** 383 384For details about the error codes, see [Display Error Codes](errorcode-display.md). 385 386| ID| Error Message| 387| ------- | ----------------------- | 388| 1400003 | This display manager service works abnormally. | 389 390**Example** 391 392```ts 393import display from '@ohos.display'; 394 395try { 396 display.getFoldDisplayMode(); 397} catch (exception) { 398 console.error('Failed to obtain the fold display mode. Code: ' + JSON.stringify(exception)); 399} 400``` 401 402## display.getCurrentFoldCreaseRegion<sup>10+</sup> 403getCurrentFoldCreaseRegion(): FoldCreaseRegion 404 405Obtains the crease region of the foldable device in the current display mode. 406 407**System capability**: SystemCapability.Window.SessionManager 408 409**Return value** 410 411| Type| Description| 412| ----------------------------------------------- | ------------------------------------------------------- | 413| [FoldCreaseRegion](#foldcreaseregion10) | Crease region of the device.| 414 415**Error codes** 416 417For details about the error codes, see [Display Error Codes](errorcode-display.md). 418 419| ID| Error Message| 420| ------- | ----------------------- | 421| 1400003 | This display manager service works abnormally. | 422 423**Example** 424 425```ts 426import display from '@ohos.display'; 427 428try { 429 display.getCurrentFoldCreaseRegion(); 430} catch (exception) { 431 console.error('Failed to obtain the current fold crease region. Code: ' + JSON.stringify(exception)); 432} 433``` 434 435## display.on('foldStatusChange')<sup>10+</sup> 436 437on(type: 'foldStatusChange', callback: Callback<FoldStatus>): void 438 439Subscribes to folding status change events of the foldable device. 440 441**System capability**: SystemCapability.Window.SessionManager 442 443**Parameters** 444 445| Name | Type | Mandatory| Description | 446| -------- |------------------------------------------| ---- | ------------------------------------------------------- | 447| type | string | Yes | Event type. The event **'foldStatusChange'** is triggered when the folding status of the device changes.| 448| callback | Callback<[FoldStatus](#foldstatus10)> | Yes | Callback used to return the folding status.| 449 450**Error codes** 451 452For details about the error codes, see [Display Error Codes](errorcode-display.md). 453 454| ID| Error Message| 455| ------- | ----------------------- | 456| 1400003 | This display manager service works abnormally. | 457 458**Example** 459 460```ts 461import { Callback } from '@ohos.base'; 462 463let callback: Callback<display.FoldStatus> = (data: display.FoldStatus) => { 464 console.info('Listening enabled. Data: ' + JSON.stringify(data)); 465}; 466try { 467 display.on('foldStatusChange', callback); 468} catch (exception) { 469 console.error('Failed to register callback. Code: ' + JSON.stringify(exception)); 470} 471``` 472 473## display.off('foldStatusChange')<sup>10+</sup> 474 475off(type: 'foldStatusChange', callback?: Callback<FoldStatus>): void 476 477Unsubscribes from folding status change events of the foldable device. 478 479**System capability**: SystemCapability.Window.SessionManager 480 481**Parameters** 482 483| Name | Type | Mandatory| Description | 484| -------- |------------------------------------------| ---- | ------------------------------------------------------- | 485| type | string | Yes | Event type. The event **'foldStatusChange'** is triggered when the folding status of the device changes.| 486| callback | Callback<[FoldStatus](#foldstatus10)> | No | Callback used for unsubscription. If this parameter is not specified, all callbacks of the current type will be unregistered.| 487 488**Error codes** 489 490For details about the error codes, see [Display Error Codes](errorcode-display.md). 491 492| ID| Error Message| 493| ------- | ----------------------- | 494| 1400003 | This display manager service works abnormally. | 495 496**Example** 497 498```ts 499try { 500 display.off('foldStatusChange'); 501} catch (exception) { 502 console.error('Failed to unregister callback. Code: ' + JSON.stringify(exception)); 503} 504``` 505 506## display.on('foldDisplayModeChange')<sup>10+</sup> 507 508on(type: 'foldDisplayModeChange', callback: Callback<FoldDisplayMode>): void 509 510Subscribes to display mode change events of the foldable device. 511 512**System capability**: SystemCapability.Window.SessionManager 513 514**Parameters** 515 516| Name | Type | Mandatory| Description | 517| -------- |------------------------------------------| ---- | ------------------------------------------------------- | 518| type | string | Yes | Event type. The event **'foldDisplayModeChange'** is triggered when the display mode of the device changes.| 519| callback | Callback<[FoldDisplayMode](#folddisplaymode10)> | Yes | Callback used to return the display mode.| 520 521**Error codes** 522 523For details about the error codes, see [Display Error Codes](errorcode-display.md). 524 525| ID| Error Message| 526| ------- | ----------------------- | 527| 1400003 | This display manager service works abnormally. | 528 529**Example** 530 531```ts 532import { Callback } from '@ohos.base'; 533 534let callback: Callback<display.FoldDisplayMode> = (data: display.FoldDisplayMode) => { 535 console.info('Listening enabled. Data: ' + JSON.stringify(data)); 536}; 537try { 538 display.on('foldDisplayModeChange', callback); 539} catch (exception) { 540 console.error('Failed to register callback. Code: ' + JSON.stringify(exception)); 541} 542``` 543 544## display.off('foldDisplayModeChange')<sup>10+</sup> 545 546off(type: 'foldDisplayModeChange', callback?: Callback<FoldDisplayMode>): void 547 548Unsubscribes from display mode change events of the foldable device. 549 550**System capability**: SystemCapability.Window.SessionManager 551 552**Parameters** 553 554| Name | Type | Mandatory| Description | 555| -------- |------------------------------------------| ---- | ------------------------------------------------------- | 556| type | string | Yes | Event type. The event **'foldDisplayModeChange'** is triggered when the display mode of the device changes.| 557| callback | Callback<[FoldDisplayMode](#folddisplaymode10)> | No | Callback used for unsubscription. If this parameter is not specified, all callbacks of the current type will be unregistered.| 558 559**Error codes** 560 561For details about the error codes, see [Display Error Codes](errorcode-display.md). 562 563| ID| Error Message| 564| ------- | ----------------------- | 565| 1400003 | This display manager service works abnormally. | 566 567**Example** 568 569```ts 570try { 571 display.off('foldDisplayModeChange'); 572} catch (exception) { 573 console.error('Failed to unregister callback. Code: ' + JSON.stringify(exception)); 574} 575``` 576 577## display.getDefaultDisplay<sup>(deprecated)</sup> 578 579getDefaultDisplay(callback: AsyncCallback<Display>): void 580 581Obtains the default display object. This API uses an asynchronous callback to return the result. 582 583> **NOTE** 584> 585> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getDefaultDisplaySync()](#displaygetdefaultdisplaysync9) instead. 586 587**System capability**: SystemCapability.WindowManager.WindowManager.Core 588 589**Parameters** 590 591| Name| Type| Mandatory| Description| 592| -------- | -------- | -------- | -------- | 593| callback | AsyncCallback<[Display](#display)> | Yes| Callback used to return the default display object.| 594 595**Example** 596 597```ts 598import { BusinessError } from '@ohos.base'; 599 600let displayClass: display.Display | null = null; 601display.getDefaultDisplay((err: BusinessError, data: display.Display) => { 602 const errCode: number = err.code; 603 if (errCode) { 604 console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(err)); 605 return; 606 } 607 console.info('Succeeded in obtaining the default display object. Data:' + JSON.stringify(data)); 608 displayClass = data; 609}); 610``` 611 612## display.getDefaultDisplay<sup>(deprecated)</sup> 613 614getDefaultDisplay(): Promise<Display> 615 616Obtains the default display object. This API uses a promise to return the result. 617 618> **NOTE** 619> 620> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getDefaultDisplaySync()](#displaygetdefaultdisplaysync9) instead. 621 622**System capability**: SystemCapability.WindowManager.WindowManager.Core 623 624**Return value** 625 626| Type | Description | 627| ---------------------------------- | ---------------------------------------------- | 628| Promise<[Display](#display)> | Promise used to return the default display object.| 629 630**Example** 631 632```ts 633import { BusinessError } from '@ohos.base'; 634 635let displayClass: display.Display | null = null; 636let promise: Promise<display.Display> = display.getDefaultDisplay(); 637promise.then((data: display.Display) => { 638 displayClass = data; 639 console.info('Succeeded in obtaining the default display object. Data:' + JSON.stringify(data)); 640}).catch((err: BusinessError) => { 641 console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(err)); 642}); 643``` 644 645## display.getAllDisplay<sup>(deprecated)</sup> 646 647getAllDisplay(callback: AsyncCallback<Array<Display>>): void 648 649Obtains all display objects. This API uses an asynchronous callback to return the result. 650 651> **NOTE** 652> 653> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getAllDisplays()](#displaygetalldisplays9) instead. 654 655**System capability**: SystemCapability.WindowManager.WindowManager.Core 656 657**Parameters** 658 659| Name | Type | Mandatory| Description | 660| -------- | ---------------------------------------------------- | ---- | ------------------------------- | 661| callback | AsyncCallback<Array<[Display](#display)>> | Yes | Callback used to return all the display objects.| 662 663**Example** 664 665```ts 666import { BusinessError } from '@ohos.base'; 667 668display.getAllDisplay((err: BusinessError, data: Array<display.Display>) => { 669 const errCode: number = err.code; 670 if (errCode) { 671 console.error('Failed to obtain all the display objects. Code: ' + JSON.stringify(err)); 672 return; 673 } 674 console.info('Succeeded in obtaining all the display objects. Data: ' + JSON.stringify(data)); 675}); 676``` 677 678## display.getAllDisplay<sup>(deprecated)</sup> 679 680getAllDisplay(): Promise<Array<Display>> 681 682Obtains all display objects. This API uses a promise to return the result. 683 684> **NOTE** 685> 686> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getAllDisplays()](#displaygetalldisplays9-1) instead. 687 688**System capability**: SystemCapability.WindowManager.WindowManager.Core 689 690**Return value** 691 692| Type | Description | 693| ----------------------------------------------- | ------------------------------------------------------- | 694| Promise<Array<[Display](#display)>> | Promise used to return all the display objects.| 695 696**Example** 697 698```ts 699import { BusinessError } from '@ohos.base'; 700 701let promise: Promise<Array<display.Display>> = display.getAllDisplay(); 702promise.then((data: Array<display.Display>) => { 703 console.info('Succeeded in obtaining all the display objects. Data: ' + JSON.stringify(data)); 704}).catch((err: BusinessError) => { 705 console.error('Failed to obtain all the display objects. Code: ' + JSON.stringify(err)); 706}); 707``` 708 709## Display 710Implements a **Display** instance, with properties and APIs defined. 711 712Before calling any API in **Display**, you must use [getAllDisplays()](#displaygetalldisplays9) or [getDefaultDisplaySync()](#displaygetdefaultdisplaysync9) to obtain a **Display** instance. 713 714### Attributes 715 716**System capability**: SystemCapability.WindowManager.WindowManager.Core 717 718| Name| Type| Readable| Writable| Description | 719| -------- | -------- | -------- | -------- |---------------------------------------------------------------------------------------------------------------| 720| id | number | Yes| No| ID of the display. The value must be an integer. | 721| name | string | Yes| No| Name of the display. | 722| alive | boolean | Yes| No| Whether the display is alive. | 723| state | [DisplayState](#displaystate) | Yes| No| State of the display. | 724| refreshRate | number | Yes| No| Refresh rate of the display, in hz. The value must be an integer. | 725| rotation | number | Yes| No| Clockwise rotation angle of the screen of the display.<br>The value **0** indicates that the screen of the display rotates clockwise by 0°.<br>The value **1** indicates that the screen of the display rotates clockwise by 90°.<br>The value **2** indicates that the screen of the display rotates clockwise by 180°.<br>The value **3** indicates that the screen of the display rotates clockwise by 270°.| 726| width | number | Yes| No| Screen width of the display, in px. The value must be an integer. | 727| height | number | Yes| No| Screen height of the display, in px. The value must be an integer. | 728| 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, in px. Generally, the value is **160.0** or **480.0**. | 729| orientation<sup>10+</sup> | [Orientation](#orientation10) | Yes| No| Orientation of the display. | 730| 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**. | 731| 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**. | 732| xDPI | number | Yes| No| Exact physical dots per inch of the screen in the horizontal direction. The value must be a floating point number. | 733| yDPI | number | Yes| No| Exact physical dots per inch of the screen in the vertical direction. The value must be a floating point number. | 734| colorSpaces<sup>11+</sup> | Array<[colorSpaceManager.ColorSpace](../apis-arkgraphics2d/js-apis-colorSpaceManager.md)> | Yes| No| All color spaces supported by the display. | 735| hdrFormats<sup>11+</sup> | Array<[hdrCapability.HDRFormat](../apis-arkgraphics2d/js-apis-hdrCapability.md)> | Yes| No| All HDR formats supported by the display. | 736 737### getCutoutInfo<sup>9+</sup> 738getCutoutInfo(callback: AsyncCallback<CutoutInfo>): void 739 740Obtains the cutout information of the display. This API uses an asynchronous callback to return the result. You are advised not to use the cutout area during application layout. 741 742**System capability**: SystemCapability.WindowManager.WindowManager.Core 743 744**Parameters** 745 746| Name | Type | Mandatory| Description | 747| ----------- | --------------------------- | ---- | ------------------------------------------------------------ | 748| callback | AsyncCallback<[CutoutInfo](#cutoutinfo9)> | Yes | Callback used to return the **CutoutInfo** object.| 749 750**Error codes** 751 752For details about the error codes, see [Display Error Codes](errorcode-display.md). 753 754| ID| Error Message| 755| ------- | ----------------------- | 756| 1400001 | Invalid display or screen. | 757 758**Example** 759 760```ts 761import { BusinessError } from '@ohos.base'; 762 763let displayClass: display.Display | null = null; 764try { 765 displayClass = display.getDefaultDisplaySync(); 766 767 displayClass.getCutoutInfo((err: BusinessError, data: display.CutoutInfo) => { 768 const errCode: number = err.code; 769 if (errCode) { 770 console.error('Failed to get cutoutInfo. Code: ' + JSON.stringify(err)); 771 return; 772 } 773 console.info('Succeeded in getting cutoutInfo. data: ' + JSON.stringify(data)); 774 }); 775} catch (exception) { 776 console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception)); 777} 778``` 779### getCutoutInfo<sup>9+</sup> 780getCutoutInfo(): Promise<CutoutInfo> 781 782Obtains the cutout information of the display. This API uses a promise to return the result. You are advised not to use the cutout area during application layout. 783 784**System capability**: SystemCapability.WindowManager.WindowManager.Core 785 786**Return value** 787 788| Type | Description | 789| ------------------- | ------------------------- | 790| Promise<[CutoutInfo](#cutoutinfo9)> | Promise used to return the **CutoutInfo** object.| 791 792**Error codes** 793 794For details about the error codes, see [Display Error Codes](errorcode-display.md). 795 796| ID| Error Message| 797| ------- | ----------------------- | 798| 1400001 | Invalid display or screen. | 799 800**Example** 801 802```ts 803import { BusinessError } from '@ohos.base'; 804 805let displayClass: display.Display | null = null; 806try { 807 displayClass = display.getDefaultDisplaySync(); 808 809 let promise: Promise<display.CutoutInfo> = displayClass.getCutoutInfo(); 810 promise.then((data: display.CutoutInfo) => { 811 console.info('Succeeded in getting cutoutInfo. Data: ' + JSON.stringify(data)); 812 }).catch((err: BusinessError) => { 813 console.error('Failed to obtain all the display objects. Code: ' + JSON.stringify(err)); 814 }); 815} catch (exception) { 816 console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception)); 817} 818``` 819