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 '@kit.ArkUI';
13```
14
15## DisplayState
16
17Enumerates the states of a display.
18
19**Atomic service API**: This API can be used in atomic services since API version 12.
20
21**System capability**: SystemCapability.WindowManager.WindowManager.Core
22
23| Name| Value| Description|
24| -------- | -------- | -------- |
25| STATE_UNKNOWN | 0 | Unknown.|
26| STATE_OFF | 1 | The display is shut down.|
27| STATE_ON | 2 | The display is powered on.|
28| STATE_DOZE | 3 | The display is in sleep mode.|
29| STATE_DOZE_SUSPEND | 4 | The display is in sleep mode, and the CPU is suspended.|
30| STATE_VR | 5 | The display is in VR mode.|
31| STATE_ON_SUSPEND | 6 | The display is powered on, and the CPU is suspended.|
32
33## Orientation<sup>10+</sup>
34
35Enumerates the orientations of a display.
36
37**Atomic service API**: This API can be used in atomic services since API version 12.
38
39**System capability**: SystemCapability.WindowManager.WindowManager.Core
40
41| Name| Value| Description|
42| -------- | -------- | -------- |
43| PORTRAIT | 0 | The display is in portrait mode.|
44| LANDSCAPE | 1 | The display is in landscape mode.|
45| PORTRAIT_INVERTED | 2 | The display is in reverse portrait mode.|
46| LANDSCAPE_INVERTED | 3 | The display is in reverse landscape mode.|
47
48## FoldStatus<sup>10+</sup>
49
50Enumerates the fold statuses of a foldable device.
51
52**Atomic service API**: This API can be used in atomic services since API version 12.
53
54**System capability**: SystemCapability.Window.SessionManager
55
56| Name| Value| Description|
57| -------- | -------- | -------- |
58| FOLD_STATUS_UNKNOWN | 0 | The fold status of the device is unknown.|
59| FOLD_STATUS_EXPANDED | 1 | The device is fully open. |
60| FOLD_STATUS_FOLDED | 2 | The device is folded (completely closed). |
61| FOLD_STATUS_HALF_FOLDED | 3 | The device is half-folded, somehow between fully open and completely closed. |
62
63## FoldDisplayMode<sup>10+</sup>
64
65Enumerates the display modes of a foldable device.
66
67**Atomic service API**: This API can be used in atomic services since API version 12.
68
69**System capability**: SystemCapability.Window.SessionManager
70
71| Name| Value| Description|
72| -------- | -------- | -------- |
73| FOLD_DISPLAY_MODE_UNKNOWN | 0 | The display mode of the device is unknown.|
74| FOLD_DISPLAY_MODE_FULL | 1 | The device is displayed in full screen.|
75| FOLD_DISPLAY_MODE_MAIN | 2 | The main screen of the device is displayed.|
76| FOLD_DISPLAY_MODE_SUB | 3 | The subscreen of the device is displayed.|
77| FOLD_DISPLAY_MODE_COORDINATION | 4 | Both screens of the device are displayed in collaborative mode.|
78
79>**NOTE**<br>
80>&bullet; For large-screen inward-foldable devices, the inner screen is the **FOLD_DISPLAY_MODE_FULL** state, and the outer screen is in the **FOLD_DISPLAY_MODE_MAIN** state.<br>
81>&bullet; For small-screen inward-foldable devices, the inner screen is the **FOLD_DISPLAY_MODE_MAIN** state, and the outer screen is in the **FOLD_DISPLAY_MODE_SUB** state.
82
83## FoldCreaseRegion<sup>10+</sup>
84
85Defines the crease region of a foldable device.
86
87**Atomic service API**: This API can be used in atomic services since API version 12.
88
89**System capability**: SystemCapability.Window.SessionManager
90
91| Name  | Type| Readable| Writable| Description              |
92| ------ | -------- | ---- | ---- | ------------------ |
93| displayId   | number   | Yes  | No  | ID of the display where the crease is located.|
94| creaseRects    | Array\<[Rect](#rect9)>   | Yes  | No  | Crease region.|
95
96## Rect<sup>9+</sup>
97
98Describes a rectangle on the display.
99
100**Atomic service API**: This API can be used in atomic services since API version 12.
101
102**System capability**: SystemCapability.WindowManager.WindowManager.Core
103
104| Name  | Type| Readable| Writable| Description              |
105| ------ | -------- | ---- | ---- | ------------------ |
106| left   | number   | Yes  | Yes  | Left boundary of the rectangle, in px. The value must be an integer.|
107| top    | number   | Yes  | Yes  | Top boundary of the rectangle, in px. The value must be an integer.|
108| width  | number   | Yes  | Yes  | Width of the rectangle, in px. The value must be an integer.  |
109| height | number   | Yes  | Yes  | Height of the rectangle, in px. The value must be an integer.  |
110
111## WaterfallDisplayAreaRects<sup>9+</sup>
112
113Describes the curved area on a waterfall display.
114
115**Atomic service API**: This API can be used in atomic services since API version 12.
116
117**System capability**: SystemCapability.WindowManager.WindowManager.Core
118
119| Name  | Type     | Readable| Writable| Description              |
120| ------ | ------------- | ---- | ---- | ------------------ |
121| left   | [Rect](#rect9) | Yes  | No  | Rectangle of the curved area on the left of the waterfall display.|
122| top    | [Rect](#rect9) | Yes  | No  | Rectangle of the curved area on the top of the waterfall display.|
123| right  | [Rect](#rect9) | Yes  | No  | Rectangle of the curved area on the right of the waterfall display.|
124| bottom | [Rect](#rect9) | Yes  | No  | Rectangle of the curved area at the bottom of the waterfall display.|
125
126## CutoutInfo<sup>9+</sup>
127
128Describes the unusable area of a display, including punch hole, notch, and curved area of a waterfall display.
129
130**Atomic service API**: This API can be used in atomic services since API version 12.
131
132**System capability**: SystemCapability.WindowManager.WindowManager.Core
133
134| Name                       | Type     | Readable| Writable| Description              |
135| --------------------------- | ------------- | ---- | ---- | ------------------ |
136| boundingRects                | Array\<[Rect](#rect9)> | Yes  | No  | Unusable areas (bounding rectangles) designed for punch holes and notches.|
137| waterfallDisplayAreaRects   | [WaterfallDisplayAreaRects](#waterfalldisplayarearects9) | Yes| No| Curved area on a waterfall display.|
138
139## DisplayPhysicalResolution<sup>12+</sup>
140Describes the display mode of a foldable device and the corresponding physical screen resolution information.
141
142**Atomic service API**: This API can be used in atomic services since API version 12.
143
144**System capability**: SystemCapability.WindowManager.WindowManager.Core
145
146| Name                       | Type     | Read-Only| Optional| Description              |
147| --------------------------- | ------------- | ---- | ---- | ------------------ |
148| foldDisplayMode             | [FoldDisplayMode](#folddisplaymode10) | Yes  | No  | Display mode of the foldable device.|
149| physicalWidth   | number | Yes| No| Width of the foldable device, in px. The value must be an integer greater than 0.|
150| physicalHeight  | number | Yes| No| Height of the foldable device, in px. The value must be an integer greater than 0.|
151
152## display.getDisplayByIdSync<sup>12+</sup>
153
154getDisplayByIdSync(displayId: number): Display
155
156Obtains a **Display** object based on the display ID.
157
158**System capability**: SystemCapability.WindowManager.WindowManager.Core
159
160**Atomic service API**: This API can be used in atomic services since API version 12.
161
162**Parameters**
163
164| Name| Type                     | Mandatory| Description      |
165| ------ | ------------------------- | ---- |----------|
166| displayId     | number                    | Yes  | Display ID. The value must be an integer greater than or equal to 0. An object can be obtained only when the passed-in display ID is correct. You can use the value of the **displayId** property in [WindowProperties](js-apis-window.md#windowproperties) as the input parameter.|
167
168**Return value**
169
170| Type                          | Description                                          |
171| ------------------------------| ----------------------------------------------|
172| [Display](#display) | **Display** object.|
173
174**Error codes**
175
176For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Display Error Codes](errorcode-display.md).
177
178| ID| Error Message|
179| ------- | ----------------------- |
180| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.2. Incorrect parameter types. 3. Parameter verification failed.|
181| 1400003 | This display manager service works abnormally. |
182
183**Example**
184
185```ts
186import { display } from '@kit.ArkUI';
187
188let displayClass: display.Display | null = null;
189
190try {
191  // Use the value of the displayId property in WindowProperties as the input parameter.
192  let displayId = 0;
193  displayClass = display.getDisplayByIdSync(displayId);
194} catch (exception) {
195  console.error(`Failed to get display. Code: ${exception.code}, message: ${exception.message}`);
196}
197```
198
199## display.getAllDisplayPhysicalResolution<sup>12+</sup>
200
201getAllDisplayPhysicalResolution(): Promise&lt;Array&lt;DisplayPhysicalResolution&gt;&gt;
202
203Obtains the display mode of the current foldable device and the corresponding physical screen resolution information.
204
205**Atomic service API**: This API can be used in atomic services since API version 12.
206
207**System capability**: SystemCapability.WindowManager.WindowManager.Core
208
209**Return value**
210
211| Type| Description|
212| ----------------------------------------------- | ------------------------------------------------------- |
213| Promise&lt;Array&lt;[DisplayPhysicalResolution](#displayphysicalresolution12)&gt;&gt; | Promise used to return all the **DisplayPhysicalResolution** objects.|
214
215**Error codes**
216
217For details about the error codes, see [Display Error Codes](errorcode-display.md).
218
219| ID| Error Message|
220| ------- | ----------------------- |
221| 1400003 | This display manager service works abnormally. |
222
223**Example**
224
225```ts
226import { BusinessError } from '@kit.BasicServicesKit';
227import { display } from '@kit.ArkUI';
228
229let promise = display.getAllDisplayPhysicalResolution();
230promise.then((resolutionObjects) => {
231  console.info('Obtaining physical resolution length: ' + resolutionObjects.length);
232  for (let i = 0; i < resolutionObjects.length; i++) {
233     console.info(`resolutionObjects[${i}].foldDisplayMode: ${resolutionObjects[i].foldDisplayMode}`);
234     console.info(`resolutionObjects[${i}].physicalWidth: ${resolutionObjects[i].physicalWidth}`);
235     console.info(`resolutionObjects[${i}].physicalHeight: ${resolutionObjects[i].physicalHeight}`);
236  }
237}).catch((err: BusinessError) => {
238  console.error(`Failed to obtain physical resolution. Code: ${err.code}, message: ${err.message}`);
239});
240```
241
242## display.getDefaultDisplaySync<sup>9+</sup>
243
244getDefaultDisplaySync(): Display
245
246Obtains the default display object. This API returns the result synchronously.
247
248**System capability**: SystemCapability.WindowManager.WindowManager.Core
249
250**Atomic service API**: This API can be used in atomic services since API version 11.
251
252**Return value**
253
254| Type                          | Description                                          |
255| ------------------------------| ----------------------------------------------|
256| [Display](#display) | Default display object.|
257
258**Error codes**
259
260For details about the error codes, see [Display Error Codes](errorcode-display.md).
261
262| ID| Error Message|
263| ------- | ----------------------- |
264| 1400001 | Invalid display or screen. |
265
266**Example**
267
268```ts
269import { display } from '@kit.ArkUI';
270
271let displayClass: display.Display | null = null;
272
273displayClass = display.getDefaultDisplaySync();
274```
275
276## display.getPrimaryDisplaySync<sup>14+</sup>
277
278getPrimaryDisplaySync(): Display
279
280Obtains the information about the primary display. For devices other than 2-in-1 devices, the **Display** object obtained is the built-in screen. For 2-in-1 devices with an external screen, the **Display** object obtained is the primary screen. For 2-in-1 devices without an external screen, the Display object obtained is the built-in screen.
281
282**System capability**: SystemCapability.WindowManager.WindowManager.Core
283
284**Atomic service API**: This API can be used in atomic services since API version 14.
285
286**Return value**
287
288| Type                          | Description                                          |
289| ------------------------------| ----------------------------------------------|
290| [Display](#display) | **Display** object of the primary screen.|
291
292**Error codes**
293
294For details about the error codes, see [Display Error Codes](errorcode-display.md).
295
296| ID| Error Message|
297| ------- | ----------------------- |
298| 1400001 | Invalid display or screen. |
299
300**Example**
301
302```ts
303import { display } from '@kit.ArkUI';
304
305let displayClass: display.Display | null = null;
306
307displayClass = display.getPrimaryDisplaySync();
308```
309
310## display.getAllDisplays<sup>9+</sup>
311
312getAllDisplays(callback: AsyncCallback&lt;Array&lt;Display&gt;&gt;): void
313
314Obtains all display objects. This API uses an asynchronous callback to return the result.
315
316**Atomic service API**: This API can be used in atomic services since API version 12.
317
318**System capability**: SystemCapability.WindowManager.WindowManager.Core
319
320**Parameters**
321
322| Name| Type| Mandatory| Description|
323| -------- | ---------------------------------------------------- | ---- | ------------------------------- |
324| callback | AsyncCallback&lt;Array&lt;[Display](#display)&gt;&gt; | Yes| Callback used to return all the display objects.|
325
326**Error codes**
327
328For details about the error codes, see [Display Error Codes](errorcode-display.md).
329
330| ID| Error Message|
331| ------- | ----------------------- |
332| 1400001 | Invalid display or screen. |
333
334**Example**
335
336```ts
337import { BusinessError } from '@kit.BasicServicesKit';
338import { display } from '@kit.ArkUI';
339
340let displayClass: Array<display.Display> = [];
341display.getAllDisplays((err: BusinessError, data: Array<display.Display>) => {
342  displayClass = data;
343  const errCode: number = err.code;
344  if (errCode) {
345    console.error(`Failed to obtain all the display objects. Code: ${err.code}, message: ${err.message}`);
346    return;
347  }
348  console.info('Succeeded in obtaining all the display objects. Data: ' + JSON.stringify(data));
349});
350```
351
352## display.getAllDisplays<sup>9+</sup>
353
354getAllDisplays(): Promise&lt;Array&lt;Display&gt;&gt;
355
356Obtains all display objects. This API uses a promise to return the result.
357
358**Atomic service API**: This API can be used in atomic services since API version 12.
359
360**System capability**: SystemCapability.WindowManager.WindowManager.Core
361
362**Return value**
363
364| Type| Description|
365| ----------------------------------------------- | ------------------------------------------------------- |
366| Promise&lt;Array&lt;[Display](#display)&gt;&gt; | Promise used to return all the display objects.|
367
368**Error codes**
369
370For details about the error codes, see [Display Error Codes](errorcode-display.md).
371
372| ID| Error Message|
373| ------- | ----------------------- |
374| 1400001 | Invalid display or screen. |
375
376**Example**
377
378```ts
379import { BusinessError } from '@kit.BasicServicesKit';
380import { display } from '@kit.ArkUI';
381
382let displayClass: Array<display.Display> =[];
383let promise: Promise<Array<display.Display>> = display.getAllDisplays();
384promise.then((data: Array<display.Display>) => {
385  displayClass = data;
386  console.info('Succeeded in obtaining all the display objects. Data: ' + JSON.stringify(data));
387}).catch((err: BusinessError) => {
388  console.error(`Failed to obtain all the display objects. Code: ${err.code}, message: ${err.message}`);
389});
390```
391
392## display.on('add'|'remove'|'change')
393
394on(type: 'add'|'remove'|'change', callback: Callback&lt;number&gt;): void
395
396Subscribes to display changes.
397
398**Atomic service API**: This API can be used in atomic services since API version 12.
399
400**System capability**: SystemCapability.WindowManager.WindowManager.Core
401
402**Parameters**
403
404| Name| Type| Mandatory| Description                                                                                                                             |
405| -------- | -------- | -------- |---------------------------------------------------------------------------------------------------------------------------------|
406| 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.|
407| callback | Callback&lt;number&gt; | Yes| Callback used to return the ID of the display, which is an integer.                                                                                                    |
408
409**Error codes**
410
411For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
412
413| ID| Error Message|
414| ------- | ----------------------- |
415| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.|
416
417**Example**
418
419```ts
420import { Callback } from '@kit.BasicServicesKit';
421
422let callback: Callback<number> = (data: number) => {
423  console.info('Listening enabled. Data: ' + JSON.stringify(data));
424};
425
426display.on("add", callback);
427```
428
429## display.off('add'|'remove'|'change')
430
431off(type: 'add'|'remove'|'change', callback?: Callback&lt;number&gt;): void
432
433Unsubscribes from display changes.
434
435**Atomic service API**: This API can be used in atomic services since API version 12.
436
437**System capability**: SystemCapability.WindowManager.WindowManager.Core
438
439**Parameters**
440
441| Name| Type| Mandatory| Description|
442| -------- | -------- | -------- | -------- |
443| 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.|
444| callback | Callback&lt;number&gt; | No| Callback used for unsubscription. If this parameter is not specified, all callbacks of the specified type will be unregistered.|
445
446**Error codes**
447
448For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
449
450| ID| Error Message|
451| ------- | ----------------------- |
452| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.|
453
454**Example**
455
456```ts
457
458// Unregister all the callbacks that have been registered through on().
459display.off("remove");
460
461let callback: Callback<number> = (data: number) => {
462  console.info('Succeeded in unregistering the callback for display remove. Data: ' + JSON.stringify(data))
463};
464// Unregister the specified callback.
465display.off('remove', callback);
466```
467
468## display.isFoldable<sup>10+</sup>
469isFoldable(): boolean
470
471Checks whether the current device is foldable.
472
473**Atomic service API**: This API can be used in atomic services since API version 12.
474
475**System capability**: SystemCapability.Window.SessionManager
476
477**Return value**
478
479| Type| Description|
480| ----------------------------------------------- | ------------------------------------------------------- |
481| boolean | Returns **true** if the device is foldable, and returns **false** otherwise.|
482
483**Error codes**
484
485For details about the error codes, see [Display Error Codes](errorcode-display.md).
486
487| ID| Error Message|
488| ------- | ----------------------- |
489| 1400003 | This display manager service works abnormally. |
490
491**Example**
492
493```ts
494import { display } from '@kit.ArkUI';
495
496let ret: boolean = false;
497ret = display.isFoldable();
498```
499
500## display.getFoldStatus<sup>10+</sup>
501getFoldStatus(): FoldStatus
502
503Obtains the fold status of the foldable device.
504
505**Atomic service API**: This API can be used in atomic services since API version 12.
506
507**System capability**: SystemCapability.Window.SessionManager
508
509**Return value**
510
511| Type| Description|
512| ----------------------------------------------- | ------------------------------------------------------- |
513| [FoldStatus](#foldstatus10) | Fold status of the device.|
514
515**Error codes**
516
517For details about the error codes, see [Display Error Codes](errorcode-display.md).
518
519| ID| Error Message|
520| ------- | ----------------------- |
521| 1400003 | This display manager service works abnormally. |
522
523**Example**
524
525```ts
526import { display } from '@kit.ArkUI';
527
528let data: display.FoldStatus = display.getFoldStatus();
529console.info('Succeeded in obtaining fold status. Data: ' + JSON.stringify(data));
530```
531
532## display.getFoldDisplayMode<sup>10+</sup>
533getFoldDisplayMode(): FoldDisplayMode
534
535Obtains the display mode of the foldable device.
536
537**Atomic service API**: This API can be used in atomic services since API version 12.
538
539**System capability**: SystemCapability.Window.SessionManager
540
541**Return value**
542
543| Type| Description|
544| ----------------------------------------------- | ------------------------------------------------------- |
545| [FoldDisplayMode](#folddisplaymode10) | Display mode of the device.|
546
547**Error codes**
548
549For details about the error codes, see [Display Error Codes](errorcode-display.md).
550
551| ID| Error Message|
552| ------- | ----------------------- |
553| 1400003 | This display manager service works abnormally. |
554
555**Example**
556
557```ts
558import { display } from '@kit.ArkUI';
559
560let data: display.FoldDisplayMode = display.getFoldDisplayMode();
561console.info('Succeeded in obtaining fold display mode. Data: ' + JSON.stringify(data));
562```
563
564## display.getCurrentFoldCreaseRegion<sup>10+</sup>
565getCurrentFoldCreaseRegion(): FoldCreaseRegion
566
567Obtains the crease region of the foldable device in the current display mode.
568
569**Atomic service API**: This API can be used in atomic services since API version 12.
570
571**System capability**: SystemCapability.Window.SessionManager
572
573**Return value**
574
575| Type| Description|
576| ----------------------------------------------- | ------------------------------------------------------- |
577| [FoldCreaseRegion](#foldcreaseregion10) | Crease region of the device.|
578
579**Error codes**
580
581For details about the error codes, see [Display Error Codes](errorcode-display.md).
582
583| ID| Error Message|
584| ------- | ----------------------- |
585| 1400003 | This display manager service works abnormally. |
586
587**Example**
588
589```ts
590import { display } from '@kit.ArkUI';
591
592let data: display.FoldCreaseRegion = display.getCurrentFoldCreaseRegion();
593console.info('Succeeded in obtaining current fold crease region. Data: ' + JSON.stringify(data));
594```
595
596## display.on('foldStatusChange')<sup>10+</sup>
597
598on(type: 'foldStatusChange', callback: Callback&lt;FoldStatus&gt;): void
599
600Subscribes to fold status change events of the foldable device.
601
602Note that [display.on('foldDisplayModeChange')](#displayonfolddisplaymodechange10) subscribes to display mode change events of the foldable device.
603
604The two are different. In terms of time sequence, the fold status changes first, and the bottom layer matches the display mode status based on the fold status.
605
606To check whether the content is displayed on the inner or outer screen of the foldable device, use [display.on('foldDisplayModeChange')](#displayonfolddisplaymodechange10).
607
608**Atomic service API**: This API can be used in atomic services since API version 12.
609
610**System capability**: SystemCapability.Window.SessionManager
611
612**Parameters**
613
614| Name  | Type                                      | Mandatory| Description                                                   |
615| -------- |------------------------------------------| ---- | ------------------------------------------------------- |
616| type     | string                                   | Yes  | Event type. The event **'foldStatusChange'** is triggered when the fold status of the device changes.|
617| callback | Callback&lt;[FoldStatus](#foldstatus10)&gt; | Yes  | Callback used to return the fold status.|
618
619**Error codes**
620
621For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Display Error Codes](errorcode-display.md).
622
623| ID| Error Message|
624| ------- | ----------------------- |
625| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.|
626| 1400003 | This display manager service works abnormally. |
627
628**Example**
629
630```ts
631import { Callback } from '@kit.BasicServicesKit';
632
633/**
634 * The callback parameter used for subscription must be passed as an object.
635 * If an anonymous function is used for registration, a new underlying object is created each time the function is called, causing memory leakage.
636*/
637let callback: Callback<display.FoldStatus> = (data: display.FoldStatus) => {
638  console.info('Listening enabled. Data: ' + JSON.stringify(data));
639};
640display.on('foldStatusChange', callback);
641```
642
643## display.off('foldStatusChange')<sup>10+</sup>
644
645off(type: 'foldStatusChange', callback?: Callback&lt;FoldStatus&gt;): void
646
647Unsubscribes from fold status change events of the foldable device.
648
649**Atomic service API**: This API can be used in atomic services since API version 12.
650
651**System capability**: SystemCapability.Window.SessionManager
652
653**Parameters**
654
655| Name  | Type                                      | Mandatory| Description                                                   |
656| -------- |------------------------------------------| ---- | ------------------------------------------------------- |
657| type     | string                                   | Yes  | Event type. The event **'foldStatusChange'** is triggered when the fold status of the device changes.|
658| callback | Callback&lt;[FoldStatus](#foldstatus10)&gt; | No  | Callback used for unsubscription. If this parameter is not specified, all callbacks of the specified type will be unregistered.|
659
660**Error codes**
661
662For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Display Error Codes](errorcode-display.md).
663
664| ID| Error Message|
665| ------- | ----------------------- |
666| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.|
667| 1400003 | This display manager service works abnormally. |
668
669**Example**
670
671```ts
672
673// Unregister all the callbacks that have been registered through on().
674display.off('foldStatusChange');
675
676let callback: Callback<display.FoldStatus> = (data: display.FoldStatus) => {
677  console.info('unregistering FoldStatus changes callback. Data: ' + JSON.stringify(data));
678};
679// Unregister the specified callback.
680display.off('foldStatusChange', callback);
681```
682
683## display.on('foldAngleChange')<sup>12+</sup>
684
685on(type: 'foldAngleChange', callback: Callback&lt;Array&lt;number&gt;&gt;): void
686
687Subscribes to folding angle change events of the foldable device.
688
689**Atomic service API**: This API can be used in atomic services since API version 12.
690
691**System capability**: SystemCapability.Window.SessionManager
692
693**Parameters**
694
695| Name  | Type                                     | Mandatory| Description                                                   |
696| -------- |------------------------------------------| ---- | ------------------------------------------------------- |
697| type     | string                                   | Yes| Event type. The event **'foldAngleChange'** is triggered when the folding angle of the device changes.|
698| callback | Callback&lt;Array&lt;number&gt;&gt; | Yes| Callback used to return the folding angle (0–180 degrees). |
699
700**Error codes**
701
702For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Display Error Codes](errorcode-display.md).
703
704| ID| Error Message|
705| ------- | ----------------------- |
706| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.|
707| 1400003 | This display manager service works abnormally. |
708
709**Example**
710
711```ts
712import { Callback } from '@kit.BasicServicesKit';
713
714let callback: Callback<Array<number>> = (angles: Array<number>) => {
715  console.info('Listening fold angles length: ' + angles.length);
716};
717display.on('foldAngleChange', callback);
718```
719
720## display.off('foldAngleChange')<sup>12+</sup>
721
722off(type: 'foldAngleChange', callback?: Callback&lt;Array&lt;number&gt;&gt;): void
723
724Unsubscribes from folding angle change events of the foldable device.
725
726**Atomic service API**: This API can be used in atomic services since API version 12.
727
728**System capability**: SystemCapability.Window.SessionManager
729
730**Parameters**
731
732| Name  | Type                                      | Mandatory| Description                                                   |
733| -------- |-------------------------------------------| ---- | ------------------------------------------------------- |
734| type     | string                                    | Yes | Event type. The event **'foldAngleChange'** is triggered when the folding angle of the device changes.|
735| callback | Callback&lt;Array&lt;number&gt;&gt; | No | Callback used for unsubscription. If this parameter is not specified, all callbacks of the specified type will be unregistered.|
736
737**Error codes**
738
739For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Display Error Codes](errorcode-display.md).
740
741| ID| Error Message|
742| ------- | ----------------------- |
743| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.|
744| 1400003 | This display manager service works abnormally. |
745
746**Example**
747
748```ts
749display.off('foldAngleChange');
750```
751
752## display.on('captureStatusChange')<sup>12+</sup>
753
754on(type: 'captureStatusChange', callback: Callback&lt;boolean&gt;): void
755
756Subscribes to screen capture, casting, or recording status changes.
757
758**Atomic service API**: This API can be used in atomic services since API version 12.
759
760**System capability**: SystemCapability.Window.SessionManager
761
762**Parameters**
763
764| Name  | Type                                      | Mandatory| Description                                                   |
765| -------- |-------------------------------------------| ---- | ------------------------------------------------------- |
766| type     | string                                   | Yes| Event type. The event **'captureStatusChange'** is triggered when the screen capture, casting, or recording status changes.|
767| callback | Callback&lt;boolean&gt; | Yes| Callback used to return the screen capture, casting, or recording status change. The value **true** means that the device starts screen capture, casting, or recording, and **false** means that the device stops screen capture, casting, or recording.|
768
769**Error codes**
770
771For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Display Error Codes](errorcode-display.md).
772
773| ID| Error Message|
774| ------- | ----------------------- |
775| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.|
776| 1400003 | This display manager service works abnormally. |
777
778**Example**
779
780```ts
781import { Callback } from '@kit.BasicServicesKit';
782
783let callback: Callback<boolean> = (captureStatus: boolean) => {
784  console.info('Listening capture status: ' + captureStatus);
785};
786display.on('captureStatusChange', callback);
787```
788
789## display.off('captureStatusChange')<sup>12+</sup>
790
791off(type: 'captureStatusChange', callback?: Callback&lt;boolean&gt;): void
792
793Unsubscribes from screen capture, casting, or recording status changes.
794
795**Atomic service API**: This API can be used in atomic services since API version 12.
796
797**System capability**: SystemCapability.Window.SessionManager
798
799**Parameters**
800
801| Name  | Type                                      | Mandatory| Description                                                   |
802| -------- |-------------------------------------------| ---- | ------------------------------------------------------- |
803| type     | string                                   | Yes| Event type. The event **'captureStatusChange'** is triggered when the screen capture, casting, or recording status changes.|
804| callback | Callback&lt;boolean&gt; | No| Callback used for unsubscription. If this parameter is not specified, all callbacks of the specified type will be unregistered.|
805
806**Error codes**
807
808For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Display Error Codes](errorcode-display.md).
809
810| ID| Error Message|
811| ------- | ----------------------- |
812| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.|
813| 1400003 | This display manager service works abnormally. |
814
815**Example**
816
817```ts
818display.off('captureStatusChange');
819```
820
821## display.isCaptured<sup>12+</sup>
822isCaptured(): boolean
823
824Checks whether the display is being captured, projected, or recorded.
825
826**Atomic service API**: This API can be used in atomic services since API version 12.
827
828**System capability**: SystemCapability.Window.SessionManager
829
830**Return value**
831
832| Type| Description|
833| ----------------------------------------------- | ------------------------------------------------------- |
834| boolean | **true**: The display is being captured, projected, or recorded.<br> **false**: The display is not being captured, projected, or recorded.|
835
836**Error codes**
837
838For details about the error codes, see [Display Error Codes](errorcode-display.md).
839
840| ID| Error Message|
841| ------- | ----------------------- |
842| 1400003 | This display manager service works abnormally. |
843
844**Example**
845
846```ts
847import { display } from '@kit.ArkUI';
848
849let ret: boolean = false;
850ret = display.isCaptured();
851```
852
853## display.on('foldDisplayModeChange')<sup>10+</sup>
854
855on(type: 'foldDisplayModeChange', callback: Callback&lt;FoldDisplayMode&gt;): void
856
857Subscribes to display mode change events of the foldable device.
858
859Subscribes to display mode change events of the foldable device. Note that [display.on('foldStatusChange')](#displayonfoldstatuschange10) subscribes to fold status change events of the foldable device.
860
861The two are different. In terms of time sequence, the fold status changes first, and the bottom layer matches the display mode status based on the fold status.
862
863**Atomic service API**: This API can be used in atomic services since API version 12.
864
865**System capability**: SystemCapability.Window.SessionManager
866
867**Parameters**
868
869| Name  | Type                                      | Mandatory| Description                                                   |
870| -------- |------------------------------------------| ---- | ------------------------------------------------------- |
871| type     | string                                   | Yes  | Event type. The event **'foldDisplayModeChange'** is triggered when the display mode of the device changes.|
872| callback | Callback&lt;[FoldDisplayMode](#folddisplaymode10)&gt; | Yes  | Callback used to return the display mode.|
873
874**Error codes**
875
876For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Display Error Codes](errorcode-display.md).
877
878| ID| Error Message|
879| ------- | ----------------------- |
880| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.|
881| 1400003 | This display manager service works abnormally. |
882
883**Example**
884
885```ts
886import { Callback } from '@kit.BasicServicesKit';
887
888/**
889 * The callback parameter used for subscription must be passed as an object.
890 * If an anonymous function is used for registration, a new underlying object is created each time the function is called, causing memory leakage.
891*/
892let callback: Callback<display.FoldDisplayMode> = (data: display.FoldDisplayMode) => {
893  console.info('Listening enabled. Data: ' + JSON.stringify(data));
894};
895display.on('foldDisplayModeChange', callback);
896```
897
898## display.off('foldDisplayModeChange')<sup>10+</sup>
899
900off(type: 'foldDisplayModeChange', callback?: Callback&lt;FoldDisplayMode&gt;): void
901
902Unsubscribes from display mode change events of the foldable device.
903
904**Atomic service API**: This API can be used in atomic services since API version 12.
905
906**System capability**: SystemCapability.Window.SessionManager
907
908**Parameters**
909
910| Name  | Type                                      | Mandatory| Description                                                   |
911| -------- |------------------------------------------| ---- | ------------------------------------------------------- |
912| type     | string                                   | Yes  | Event type. The event **'foldDisplayModeChange'** is triggered when the display mode of the device changes.|
913| callback | Callback&lt;[FoldDisplayMode](#folddisplaymode10)&gt; | No  | Callback used for unsubscription. If this parameter is not specified, all callbacks of the specified type will be unregistered.|
914
915**Error codes**
916
917For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Display Error Codes](errorcode-display.md).
918
919| ID| Error Message|
920| ------- | ----------------------- |
921| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.|
922| 1400003 | This display manager service works abnormally. |
923
924**Example**
925
926```ts
927
928// Unregister all the callbacks that have been registered through on().
929display.off('foldDisplayModeChange');
930
931let callback: Callback<display.FoldDisplayMode> = (data: display.FoldDisplayMode) => {
932  console.info('unregistering FoldDisplayMode changes callback. Data: ' + JSON.stringify(data));
933};
934// Unregister the specified callback.
935display.off('foldDisplayModeChange', callback);
936```
937
938
939## display.getDefaultDisplay<sup>(deprecated)</sup>
940
941getDefaultDisplay(callback: AsyncCallback&lt;Display&gt;): void
942
943Obtains the default display object. This API uses an asynchronous callback to return the result.
944
945> **NOTE**
946>
947> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getDefaultDisplaySync()](#displaygetdefaultdisplaysync9) instead.
948
949**System capability**: SystemCapability.WindowManager.WindowManager.Core
950
951**Parameters**
952
953| Name| Type| Mandatory| Description|
954| -------- | -------- | -------- | -------- |
955| callback | AsyncCallback&lt;[Display](#display)&gt; | Yes| Callback used to return the default display object.|
956
957**Example**
958
959```ts
960import { BusinessError } from '@kit.BasicServicesKit';
961
962let displayClass: display.Display | null = null;
963display.getDefaultDisplay((err: BusinessError, data: display.Display) => {
964  const errCode: number = err.code;
965  if (errCode) {
966    console.error(`Failed to obtain the default display object. Code: ${err.code}, message: ${err.message}`);
967    return;
968  }
969  console.info('Succeeded in obtaining the default display object. Data:' + JSON.stringify(data));
970  displayClass = data;
971});
972```
973
974## display.getDefaultDisplay<sup>(deprecated)</sup>
975
976getDefaultDisplay(): Promise&lt;Display&gt;
977
978Obtains the default display object. This API uses a promise to return the result.
979
980> **NOTE**
981>
982> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getDefaultDisplaySync()](#displaygetdefaultdisplaysync9) instead.
983
984**System capability**: SystemCapability.WindowManager.WindowManager.Core
985
986**Return value**
987
988| Type                              | Description                                          |
989| ---------------------------------- | ---------------------------------------------- |
990| Promise&lt;[Display](#display)&gt; | Promise used to return the default display object.|
991
992**Example**
993
994```ts
995import { BusinessError } from '@kit.BasicServicesKit';
996
997let displayClass: display.Display | null = null;
998let promise: Promise<display.Display> = display.getDefaultDisplay();
999promise.then((data: display.Display) => {
1000  displayClass = data;
1001  console.info('Succeeded in obtaining the default display object. Data:' + JSON.stringify(data));
1002}).catch((err: BusinessError) => {
1003  console.error(`Failed to obtain the default display object. Code: ${err.code}, message: ${err.message}`);
1004});
1005```
1006
1007## display.getAllDisplay<sup>(deprecated)</sup>
1008
1009getAllDisplay(callback: AsyncCallback&lt;Array&lt;Display&gt;&gt;): void
1010
1011Obtains all display objects. This API uses an asynchronous callback to return the result.
1012
1013> **NOTE**
1014>
1015> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getAllDisplays()](#displaygetalldisplays9) instead.
1016
1017**System capability**: SystemCapability.WindowManager.WindowManager.Core
1018
1019**Parameters**
1020
1021| Name  | Type                                                | Mandatory| Description                           |
1022| -------- | ---------------------------------------------------- | ---- | ------------------------------- |
1023| callback | AsyncCallback&lt;Array&lt;[Display](#display)&gt;&gt; | Yes  | Callback used to return all the display objects.|
1024
1025**Example**
1026
1027```ts
1028import { BusinessError } from '@kit.BasicServicesKit';
1029
1030display.getAllDisplay((err: BusinessError, data: Array<display.Display>) => {
1031  const errCode: number = err.code;
1032  if (errCode) {
1033    console.error(`Failed to obtain all the display objects. Code: ${err.code}, message: ${err.message}`);
1034    return;
1035  }
1036  console.info('Succeeded in obtaining all the display objects. Data: ' + JSON.stringify(data));
1037});
1038```
1039
1040## display.getAllDisplay<sup>(deprecated)</sup>
1041
1042getAllDisplay(): Promise&lt;Array&lt;Display&gt;&gt;
1043
1044Obtains all display objects. This API uses a promise to return the result.
1045
1046> **NOTE**
1047>
1048> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getAllDisplays()](#displaygetalldisplays9-1) instead.
1049
1050**System capability**: SystemCapability.WindowManager.WindowManager.Core
1051
1052**Return value**
1053
1054| Type                                           | Description                                                   |
1055| ----------------------------------------------- | ------------------------------------------------------- |
1056| Promise&lt;Array&lt;[Display](#display)&gt;&gt; | Promise used to return all the display objects.|
1057
1058**Example**
1059
1060```ts
1061import { BusinessError } from '@kit.BasicServicesKit';
1062
1063let promise: Promise<Array<display.Display>> = display.getAllDisplay();
1064promise.then((data: Array<display.Display>) => {
1065  console.info('Succeeded in obtaining all the display objects. Data: ' + JSON.stringify(data));
1066}).catch((err: BusinessError) => {
1067  console.error(`Failed to obtain all the display objects. Code: ${err.code}, message: ${err.message}`);
1068});
1069```
1070
1071## Display
1072Implements a **Display** instance, with properties and APIs defined.
1073
1074Before calling any API in **Display**, you must use [getAllDisplays()](#displaygetalldisplays9) or [getDefaultDisplaySync()](#displaygetdefaultdisplaysync9) to obtain a **Display** instance.
1075
1076### Properties
1077
1078**System capability**: SystemCapability.WindowManager.WindowManager.Core
1079
1080| Name| Type| Read-Only| Optional| Description                                                                                                           |
1081| -------- | -------- | -------- | -------- |---------------------------------------------------------------------------------------------------------------|
1082| id | number | Yes| No| ID of the display. The value must be an integer.<br>**Atomic service API**: This API can be used in atomic services since API version 12.                                                                                            |
1083| name | string | Yes| No| Name of the display.<br>**Atomic service API**: This API can be used in atomic services since API version 12.                                                                                                     |
1084| alive | boolean | Yes| No| Whether the display is alive.<br>**Atomic service API**: This API can be used in atomic services since API version 12.                                                                                                    |
1085| state | [DisplayState](#displaystate) | Yes| No| State of the display.<br>**Atomic service API**: This API can be used in atomic services since API version 12.                                                                                                     |
1086| refreshRate | number | Yes| No| Refresh rate of the display, in hz. The value must be an integer.<br>**Atomic service API**: This API can be used in atomic services since API version 12.                                                                                            |
1087| rotation | number | Yes| No| Clockwise rotation angle of the display.<br>The value **0** indicates that the display rotates clockwise by 0°.<br>The value **1** indicates that the display rotates clockwise by 90°.<br>The value **2** indicates that the display rotates clockwise by 180°.<br>The value **3** indicates that the display rotates clockwise by 270°.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
1088| width | number | Yes| No| Width of the display, in px. The value must be an integer.<br>**Atomic service API**: This API can be used in atomic services since API version 11.                                                                                       |
1089| height | number | Yes| No| Height of the display, in px. The value must be an integer.<br>**Atomic service API**: This API can be used in atomic services since API version 11.                                                                                       |
1090| densityDPI | number | Yes| No| Physical pixel density of the display, that is, the number of pixels per inch. The value is a floating point number, in px. Generally, the value is **160.0** or **480.0**. The actual value depends on the optional values provided by the device in use.<br>**Atomic service API**: This API can be used in atomic services since API version 12.                                                                  |
1091| orientation<sup>10+</sup> | [Orientation](#orientation10) | Yes| No| Orientation of the display.<br>**Atomic service API**: This API can be used in atomic services since API version 12.                                                                                                 |
1092| densityPixels | number | Yes| No| Logical pixel density of the display, which is the scaling coefficient between physical pixels and logical pixels. The calculation method is as follows:<br>![densityPixels](figures/densityPixels.jpg)<br>The value is a floating point number and is restricted by the range of **densityDPI**. The value range is [0.5, 4.0]. Generally, the value is **1.0** or **3.0**. The actual value depends on the density DPI provided by the device in use.<br>**Atomic service API**: This API can be used in atomic services since API version 11.                                                                 |
1093| 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**.<br>**Atomic service API**: This API can be used in atomic services since API version 12.                                                                   |
1094| xDPI | number | Yes| No| Exact physical pixels per inch of the display in the X dimension. The value must be a floating point number.<br>**Atomic service API**: This API can be used in atomic services since API version 12.                                                                                   |
1095| yDPI | number | Yes| No| Exact physical pixels per inch of the display in the Y dimension. The value must be a floating point number.<br>**Atomic service API**: This API can be used in atomic services since API version 12.                                                                                   |
1096| colorSpaces<sup>11+</sup> | Array<[colorSpaceManager.ColorSpace](../apis-arkgraphics2d/js-apis-colorSpaceManager.md)> | Yes| No| All color spaces supported by the display.<br>**Atomic service API**: This API can be used in atomic services since API version 12.                                                                                               |
1097| hdrFormats<sup>11+</sup> | Array<[hdrCapability.HDRFormat](../apis-arkgraphics2d/js-apis-hdrCapability.md)> | Yes| No| All HDR formats supported by the display.<br>**Atomic service API**: This API can be used in atomic services since API version 12.                                                                                              |
1098| availableWidth<sup>12+</sup> | number | Yes| No| Width of the available area on a 2-in-1 device, in px. The value is an integer greater than 0.<br>**Atomic service API**: This API can be used in atomic services since API version 12.                                                                                   |
1099| availableHeight<sup>12+</sup> | number | Yes| No| Height of the available area on a 2-in-1 device, in px. The value is an integer greater than 0.<br>**Atomic service API**: This API can be used in atomic services since API version 12.                                                                                   |
1100
1101### getCutoutInfo<sup>9+</sup>
1102getCutoutInfo(callback: AsyncCallback&lt;CutoutInfo&gt;): void
1103
1104Obtains 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.
1105
1106**Atomic service API**: This API can be used in atomic services since API version 12.
1107
1108**System capability**: SystemCapability.WindowManager.WindowManager.Core
1109
1110**Parameters**
1111
1112| Name     | Type                       | Mandatory| Description                                                        |
1113| ----------- | --------------------------- | ---- | ------------------------------------------------------------ |
1114| callback    | AsyncCallback&lt;[CutoutInfo](#cutoutinfo9)&gt;   | Yes  | Callback used to return the **CutoutInfo** object.|
1115
1116**Error codes**
1117
1118For details about the error codes, see [Display Error Codes](errorcode-display.md).
1119
1120| ID| Error Message|
1121| ------- | ----------------------- |
1122| 1400001 | Invalid display or screen. |
1123
1124**Example**
1125
1126```ts
1127import { BusinessError } from '@kit.BasicServicesKit';
1128
1129let displayClass: display.Display | null = null;
1130displayClass = display.getDefaultDisplaySync();
1131
1132displayClass.getCutoutInfo((err: BusinessError, data: display.CutoutInfo) => {
1133  const errCode: number = err.code;
1134  if (errCode) {
1135    console.error(`Failed to get cutoutInfo. Code: ${err.code}, message: ${err.message}`);
1136    return;
1137  }
1138  console.info('Succeeded in getting cutoutInfo. data: ' + JSON.stringify(data));
1139});
1140```
1141### getCutoutInfo<sup>9+</sup>
1142getCutoutInfo(): Promise&lt;CutoutInfo&gt;
1143
1144Obtains 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.
1145
1146**Atomic service API**: This API can be used in atomic services since API version 12.
1147
1148**System capability**: SystemCapability.WindowManager.WindowManager.Core
1149
1150**Return value**
1151
1152| Type               | Description                     |
1153| ------------------- | ------------------------- |
1154| Promise&lt;[CutoutInfo](#cutoutinfo9)&gt; | Promise used to return the **CutoutInfo** object.|
1155
1156**Error codes**
1157
1158For details about the error codes, see [Display Error Codes](errorcode-display.md).
1159
1160| ID| Error Message|
1161| ------- | ----------------------- |
1162| 1400001 | Invalid display or screen. |
1163
1164**Example**
1165
1166```ts
1167import { BusinessError } from '@kit.BasicServicesKit';
1168
1169let displayClass: display.Display | null = null;
1170displayClass = display.getDefaultDisplaySync();
1171let promise: Promise<display.CutoutInfo> = displayClass.getCutoutInfo();
1172promise.then((data: display.CutoutInfo) => {
1173  console.info('Succeeded in getting cutoutInfo. Data: ' + JSON.stringify(data));
1174}).catch((err: BusinessError) => {
1175  console.error(`Failed to obtain all the display objects. Code: ${err.code}, message: ${err.message}`);
1176});
1177```
1178
1179### getAvailableArea<sup>12+</sup>
1180getAvailableArea(): Promise&lt;Rect&gt;
1181
1182Obtains the available area of the display of the current device. This API uses a promise to return the result.
1183
1184**Atomic service API**: This API can be used in atomic services since API version 12.
1185
1186**System capability**: SystemCapability.Window.SessionManager
1187
1188**Return value**
1189
1190| Type               | Description                     |
1191| ------------------- | ------------------------- |
1192| Promise&lt;[Rect](#rect9)&gt; | Promise used to return the available area, which is a rectangle.|
1193
1194**Error codes**
1195
1196For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Display Error Codes](errorcode-display.md).
1197
1198| ID| Error Message|
1199| ------- | ----------------------- |
1200| 801 | Capability not supported. Failed to call the API due to limited device capabilities. |
1201| 1400001 | Invalid display or screen. |
1202
1203**Example**
1204
1205```ts
1206import { BusinessError } from '@kit.BasicServicesKit';
1207import { display } from '@kit.ArkUI';
1208
1209let displayClass: display.Display | null = null;
1210try {
1211  displayClass = display.getDefaultDisplaySync();
1212  let promise = displayClass.getAvailableArea();
1213  promise.then((data) => {
1214    console.info('Succeeded get the available area in this display. data: ' + JSON.stringify(data));
1215  }).catch((err: BusinessError) => {
1216    console.error(`Failed to get the available area in this display. Code: ${err.code}, message: ${err.message}`);
1217  })
1218} catch (exception) {
1219  console.error(`Failed to obtain the default display object. Code: ${exception.code}, message: ${exception.message}`);
1220}
1221```
1222
1223### on('availableAreaChange')<sup>12+</sup>
1224on(type: 'availableAreaChange', callback: Callback&lt;Rect&gt;): void
1225
1226Subscribes to changes of the available area on the display of the current device. This API uses an asynchronous callback to return the result.
1227
1228**Atomic service API**: This API can be used in atomic services since API version 12.
1229
1230**System capability**: SystemCapability.Window.SessionManager
1231
1232**Parameters**
1233
1234| Name  | Type                                      | Mandatory| Description                                                   |
1235| -------- |------------------------------------------| ---- | ------------------------------------------------------- |
1236| type     | string                                   | Yes  | Event type. The event **'availableAreaChange'** is triggered when the available area of the display changes.|
1237| callback | Callback&lt;[Rect](#rect9)&gt; | Yes  | Callback used to return the new available area.|
1238
1239**Error codes**
1240
1241For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Display Error Codes](errorcode-display.md).
1242
1243| ID| Error Message|
1244| ------- | ----------------------- |
1245| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.|
1246| 801 | Capability not supported. Failed to call the API due to limited device capabilities. |
1247| 1400003 | This display manager service works abnormally. |
1248
1249**Example**
1250
1251```ts
1252import { Callback } from '@kit.BasicServicesKit';
1253import { display } from '@kit.ArkUI';
1254
1255let callback: Callback<display.Rect> = (data: display.Rect) => {
1256  console.info('Listening enabled. Data: ' + JSON.stringify(data));
1257};
1258let displayClass: display.Display | null = null;
1259try {
1260  displayClass = display.getDefaultDisplaySync();
1261  displayClass.on("availableAreaChange", callback);
1262} catch (exception) {
1263  console.error(`Failed to register callback. Code: ${exception.code}, message: ${exception.message}`);
1264}
1265```
1266
1267### off('availableAreaChange')<sup>12+</sup>
1268
1269off(type: 'availableAreaChange', callback?: Callback&lt;Rect&gt;): void
1270
1271Unsubscribes from changes of the available area on the display of the current device.
1272
1273**Atomic service API**: This API can be used in atomic services since API version 12.
1274
1275**System capability**: SystemCapability.Window.SessionManager
1276
1277**Parameters**
1278
1279| Name  | Type                                      | Mandatory| Description                                                   |
1280| -------- |------------------------------------------| ---- | ------------------------------------------------------- |
1281| type     | string                                   | Yes  | Event type. The event **'availableAreaChange'** is triggered when the available area of the display changes.|
1282| callback | Callback&lt;[Rect](#rect9)&gt; | No  | Callback used for unsubscription. If no value is passed in, all subscriptions to the specified event are canceled.|
1283
1284**Error codes**
1285
1286For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Display Error Codes](errorcode-display.md).
1287
1288| ID| Error Message|
1289| ------- | ----------------------- |
1290| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.|
1291| 801 | Capability not supported. Failed to call the API due to limited device capabilities. |
1292| 1400003 | This display manager service works abnormally. |
1293
1294**Example**
1295
1296```ts
1297import { Callback } from '@kit.BasicServicesKit';
1298import { display } from '@kit.ArkUI';
1299
1300let callback: Callback<display.Rect> = (data: display.Rect) => {
1301  console.info('Listening enabled. Data: ' + JSON.stringify(data));
1302};
1303let displayClass: display.Display | null = null;
1304try {
1305  displayClass = display.getDefaultDisplaySync();
1306  displayClass.off("availableAreaChange", callback);
1307} catch (exception) {
1308  console.error(`Failed to unregister callback. Code: ${exception.code}, message: ${exception.message}`);
1309}
1310```
1311