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