• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import type { AsyncCallback, Callback } from './@ohos.base';
17
18/**
19 * Interface of display manager.
20 *
21 * @namespace display
22 * @syscap SystemCapability.WindowManager.WindowManager.Core
23 * @since 7
24 */
25/**
26 * Interface of display manager.
27 *
28 * @namespace display
29 * @syscap SystemCapability.WindowManager.WindowManager.Core
30 * @crossplatform
31 * @since 10
32 */
33declare namespace display {
34  /**
35   * Obtain the default display.
36   *
37   * @param { AsyncCallback<Display> } callback the result of display
38   * @syscap SystemCapability.WindowManager.WindowManager.Core
39   * @since 7
40   * @deprecated since 9
41   * @useinstead ohos.display#getDefaultDisplaySync
42   */
43  function getDefaultDisplay(callback: AsyncCallback<Display>): void;
44
45  /**
46   * Obtain the default display.
47   *
48   * @returns { Promise<Display> } the result of display
49   * @syscap SystemCapability.WindowManager.WindowManager.Core
50   * @since 7
51   * @deprecated since 9
52   * @useinstead ohos.display#getDefaultDisplaySync
53   */
54  function getDefaultDisplay(): Promise<Display>;
55
56  /**
57   * Obtain the default display.
58   *
59   * @returns { Display } the result of display
60   * @throws { BusinessError } 1400001 - Invalid display or screen.
61   * @syscap SystemCapability.WindowManager.WindowManager.Core
62   * @since 9
63   */
64  /**
65   * Obtain the default display.
66   *
67   * @returns { Display } the result of display
68   * @throws { BusinessError } 1400001 - Invalid display or screen.
69   * @syscap SystemCapability.WindowManager.WindowManager.Core
70   * @crossplatform
71   * @since 10
72   */
73  function getDefaultDisplaySync(): Display;
74
75  /**
76   * Obtain all displays.
77   *
78   * @param { AsyncCallback<Array<Display>> } callback the result of all displays
79   * @syscap SystemCapability.WindowManager.WindowManager.Core
80   * @since 7
81   * @deprecated since 9
82   * @useinstead ohos.display#getAllDisplays
83   */
84  function getAllDisplay(callback: AsyncCallback<Array<Display>>): void;
85
86  /**
87   * Obtain all displays.
88   *
89   * @returns { Promise<Array<Display>> } the result of all displays
90   * @syscap SystemCapability.WindowManager.WindowManager.Core
91   * @since 7
92   * @deprecated since 9
93   * @useinstead ohos.display#getAllDisplays
94   */
95  function getAllDisplay(): Promise<Array<Display>>;
96
97  /**
98   * Obtain all displays.
99   *
100   * @param { AsyncCallback<Array<Display>> } callback the result of all displays
101   * @throws { BusinessError } 1400001 - Invalid display or screen.
102   * @syscap SystemCapability.WindowManager.WindowManager.Core
103   * @since 9
104   */
105  function getAllDisplays(callback: AsyncCallback<Array<Display>>): void;
106
107  /**
108   * Obtain all displays.
109   *
110   * @returns { Promise<Array<Display>> } the result of all displays
111   * @throws { BusinessError } 1400001 - Invalid display or screen.
112   * @syscap SystemCapability.WindowManager.WindowManager.Core
113   * @since 9
114   */
115  function getAllDisplays(): Promise<Array<Display>>;
116
117  /**
118   * Check whether there is a privacy window on the current display.
119   *
120   * @param { number } displayId Display id to query
121   * @returns { boolean } true means there is a privacy window on the current display
122   * @throws { BusinessError } 401 - Parameter error.
123   * @throws { BusinessError } 1400003 - This display manager service works abnormally.
124   * @syscap SystemCapability.WindowManager.WindowManager.Core
125   * @systemapi Hide this for inner system use.
126   * @since 9
127   */
128  function hasPrivateWindow(displayId: number): boolean;
129
130  /**
131   * Register the callback for display changes.
132   *
133   * @param { 'add' | 'remove' | 'change' } type the event of display change
134   * @param { Callback<number> } callback the display id of changed
135   * @throws { BusinessError } 401 - Parameter error.
136   * @syscap SystemCapability.WindowManager.WindowManager.Core
137   * @since 7
138   */
139  function on(type: 'add' | 'remove' | 'change', callback: Callback<number>): void;
140
141  /**
142   * Unregister the callback for display changes.
143   *
144   * @param { 'add' | 'remove' | 'change' } type the event of display change event
145   * @param { Callback<number> } callback the display id of changed
146   * @throws { BusinessError } 401 - Parameter error.
147   * @syscap SystemCapability.WindowManager.WindowManager.Core
148   * @since 7
149   */
150  function off(type: 'add' | 'remove' | 'change', callback?: Callback<number>): void;
151
152  /**
153   * Register the callback for private mode changes.
154   *
155   * @param { 'privateModeChange' } type the event of private mode changes
156   * @param { Callback<boolean> } callback Callback used to return the result whether display is on private mode or not
157   * @throws { BusinessError } 401 - Parameter error.
158   * @syscap SystemCapability.WindowManager.WindowManager.Core
159   * @systemapi Hide this for inner system use.
160   * @since 10
161   */
162  function on(type: 'privateModeChange', callback: Callback<boolean>): void;
163
164  /**
165   * Unregister the callback for private mode changes.
166   *
167   * @param { 'privateModeChange' } type the event of private mode changes
168   * @param { Callback<boolean> } callback Callback used to return the result whether display is on private mode or not
169   * @throws { BusinessError } 401 - Parameter error.
170   * @syscap SystemCapability.WindowManager.WindowManager.Core
171   * @systemapi Hide this for inner system use.
172   * @since 10
173   */
174  function off(type: 'privateModeChange', callback?: Callback<boolean>): void;
175
176  /**
177   * Check whether the device is foldable.
178   *
179   * @returns { boolean } true means the device is foldable.
180   * @throws { BusinessError } 801 - Capability not supported on this device.
181   * @throws { BusinessError } 1400003 - This display manager service works abnormally.
182   * @syscap SystemCapability.Window.SessionManager
183   * @since 10
184   */
185  function isFoldable(): boolean;
186
187  /**
188   * Get the current fold status of the foldable device.
189   *
190   * @returns { FoldStatus } fold status of device.
191   * @throws { BusinessError } 801 - Capability not supported on this device.
192   * @throws { BusinessError } 1400003 - This display manager service works abnormally.
193   * @syscap SystemCapability.Window.SessionManager
194   * @since 10
195   */
196  function getFoldStatus(): FoldStatus;
197
198  /**
199   * Register the callback for fold status changes.
200   *
201   * @param { 'foldStatusChange' } type the event of fold status changes
202   * @param { Callback<FoldStatus> } callback Callback used to return the current fold status of device
203   * @throws { BusinessError } 401 - Parameter error.
204   * @throws { BusinessError } 801 - Capability not supported on this device.
205   * @throws { BusinessError } 1400003 - This display manager service works abnormally.
206   * @syscap SystemCapability.Window.SessionManager
207   * @since 10
208   */
209  function on(type: 'foldStatusChange', callback: Callback<FoldStatus>): void;
210
211  /**
212   * Unregister the callback for fold status changes.
213   *
214   * @param { 'foldStatusChange' } type the event of fold status changes
215   * @param { Callback<FoldStatus> } callback Callback used to return the current fold status of device
216   * @throws { BusinessError } 401 - Parameter error.
217   * @throws { BusinessError } 801 - Capability not supported on this device.
218   * @throws { BusinessError } 1400003 - This display manager service works abnormally.
219   * @syscap SystemCapability.Window.SessionManager
220   * @since 10
221   */
222  function off(type: 'foldStatusChange', callback?: Callback<FoldStatus>): void;
223
224  /**
225   * Get the display mode of the foldable device.
226   *
227   * @returns { FoldDisplayMode } display mode of the foldable device.
228   * @throws { BusinessError } 801 - Capability not supported on this device.
229   * @throws { BusinessError } 1400003 - This display manager service works abnormally.
230   * @syscap SystemCapability.Window.SessionManager
231   * @since 10
232   */
233  function getFoldDisplayMode(): FoldDisplayMode;
234
235  /**
236   * Change the display mode of the foldable device.
237   *
238   * @param { FoldDisplayMode } mode target display mode to change.
239   * @throws { BusinessError } 202 - Permission verification failed, non-system application uses system API.
240   * @throws { BusinessError } 401 - Parameter error.
241   * @throws { BusinessError } 801 - Capability not supported on this device.
242   * @throws { BusinessError } 1400003 - This display manager service works abnormally.
243   * @syscap SystemCapability.Window.SessionManager
244   * @systemapi Hide this for inner system use.
245   * @since 10
246   */
247  function setFoldDisplayMode(mode: FoldDisplayMode): void;
248
249  /**
250   * Register the callback for fold display mode changes.
251   *
252   * @param { 'foldDisplayModeChange' } type the event of fold display mode changes
253   * @param { Callback<FoldDisplayMode> } callback Callback used to return the current fold display mode
254   * @throws { BusinessError } 401 - Parameter error.
255   * @throws { BusinessError } 801 - Capability not supported on this device.
256   * @throws { BusinessError } 1400003 - This display manager service works abnormally.
257   * @syscap SystemCapability.Window.SessionManager
258   * @since 10
259   */
260  function on(type: 'foldDisplayModeChange', callback: Callback<FoldDisplayMode>): void;
261
262  /**
263   * Unregister the callback for fold display mode changes.
264   *
265   * @param { 'foldDisplayModeChange' } type the event of fold display mode changes
266   * @param { Callback<FoldDisplayMode> } callback Callback used to return the current fold display mode
267   * @throws { BusinessError } 401 - Parameter error.
268   * @throws { BusinessError } 801 - Capability not supported on this device.
269   * @throws { BusinessError } 1400003 - This display manager service works abnormally.
270   * @syscap SystemCapability.Window.SessionManager
271   * @since 10
272   */
273  function off(type: 'foldDisplayModeChange', callback?: Callback<FoldDisplayMode>): void;
274
275  /**
276   * Get the fold crease region in the current display mode.
277   *
278   * @returns { FoldCreaseRegion } fold crease region in the current display mode.
279   * @throws { BusinessError } 801 - Capability not supported on this device.
280   * @throws { BusinessError } 1400003 - This display manager service works abnormally.
281   * @syscap SystemCapability.Window.SessionManager
282   * @since 10
283   */
284  function getCurrentFoldCreaseRegion(): FoldCreaseRegion;
285
286  /**
287   * Enumerates the fold status.
288   *
289   * @enum { number }
290   * @syscap SystemCapability.Window.SessionManager
291   * @since 10
292   */
293  enum FoldStatus {
294    /**
295     * Fold Status Unknown.
296     *
297     * @syscap SystemCapability.Window.SessionManager
298     * @since 10
299     */
300    FOLD_STATUS_UNKNOWN = 0,
301    /**
302     * Fold Status Expanded.
303     *
304     * @syscap SystemCapability.Window.SessionManager
305     * @since 10
306     */
307    FOLD_STATUS_EXPANDED,
308    /**
309     * Fold Status Folded.
310     *
311     * @syscap SystemCapability.Window.SessionManager
312     * @since 10
313     */
314    FOLD_STATUS_FOLDED,
315    /**
316     * Fold Status Half Folded.
317     *
318     * @syscap SystemCapability.Window.SessionManager
319     * @since 10
320     */
321    FOLD_STATUS_HALF_FOLDED
322  }
323
324  /**
325   * Enumerates the fold display mode.
326   *
327   * @enum { number }
328   * @syscap SystemCapability.Window.SessionManager
329   * @since 10
330   */
331  enum FoldDisplayMode {
332    /**
333     * Unknown Display.
334     *
335     * @syscap SystemCapability.Window.SessionManager
336     * @since 10
337     */
338    FOLD_DISPLAY_MODE_UNKNOWN = 0,
339    /**
340     * Full Display.
341     *
342     * @syscap SystemCapability.Window.SessionManager
343     * @since 10
344     */
345    FOLD_DISPLAY_MODE_FULL,
346    /**
347     * Main Display.
348     *
349     * @syscap SystemCapability.Window.SessionManager
350     * @since 10
351     */
352    FOLD_DISPLAY_MODE_MAIN,
353    /**
354     * Sub Display.
355     *
356     * @syscap SystemCapability.Window.SessionManager
357     * @since 10
358     */
359    FOLD_DISPLAY_MODE_SUB,
360    /**
361     * Coordination Display.
362     *
363     * @syscap SystemCapability.Window.SessionManager
364     * @since 10
365     */
366    FOLD_DISPLAY_MODE_COORDINATION
367  }
368
369  /**
370   * Enumerates the display states.
371   *
372   * @enum { number }
373   * @syscap SystemCapability.WindowManager.WindowManager.Core
374   * @since 7
375   */
376  enum DisplayState {
377    /**
378     * Unknown.
379     *
380     * @syscap SystemCapability.WindowManager.WindowManager.Core
381     * @since 7
382     */
383    STATE_UNKNOWN = 0,
384    /**
385     * Screen off.
386     *
387     * @syscap SystemCapability.WindowManager.WindowManager.Core
388     * @since 7
389     */
390    STATE_OFF,
391    /**
392     * Screen on.
393     *
394     * @syscap SystemCapability.WindowManager.WindowManager.Core
395     * @since 7
396     */
397    STATE_ON,
398    /**
399     * Doze, but it will update for some important system messages.
400     *
401     * @syscap SystemCapability.WindowManager.WindowManager.Core
402     * @since 7
403     */
404    STATE_DOZE,
405    /**
406     * Doze and not update.
407     *
408     * @syscap SystemCapability.WindowManager.WindowManager.Core
409     * @since 7
410     */
411    STATE_DOZE_SUSPEND,
412    /**
413     * VR node.
414     *
415     * @syscap SystemCapability.WindowManager.WindowManager.Core
416     * @since 7
417     */
418    STATE_VR,
419    /**
420     * Screen on and not update.
421     *
422     * @syscap SystemCapability.WindowManager.WindowManager.Core
423     * @since 7
424     */
425    STATE_ON_SUSPEND
426  }
427
428  /**
429   * Enumerates the display orientation.
430   *
431   * @enum { number }
432   * @syscap SystemCapability.WindowManager.WindowManager.Core
433   * @crossplatform
434   * @since 10
435   */
436  enum Orientation {
437    /**
438     * Indicate that the display content is in portrait mode.
439     *
440     * @syscap SystemCapability.WindowManager.WindowManager.Core
441     * @crossplatform
442     * @since 10
443     */
444    PORTRAIT = 0,
445
446    /**
447     * Indicate that the display content is in landscape mode.
448     *
449     * @syscap SystemCapability.WindowManager.WindowManager.Core
450     * @crossplatform
451     * @since 10
452     */
453    LANDSCAPE = 1,
454
455    /**
456     * Indicate that the display content is in the opposite direction of the portrait mode.
457     *
458     * @syscap SystemCapability.WindowManager.WindowManager.Core
459     * @crossplatform
460     * @since 10
461     */
462    PORTRAIT_INVERTED = 2,
463
464    /**
465     * Indicate that the display content is in the opposite direction of the landscape mode.
466     *
467     * @syscap SystemCapability.WindowManager.WindowManager.Core
468     * @crossplatform
469     * @since 10
470     */
471    LANDSCAPE_INVERTED = 3
472  }
473
474  /**
475   * Fold Crease Region
476   *
477   * @interface FoldCreaseRegion
478   * @syscap SystemCapability.Window.SessionManager
479   * @since 10
480   */
481  interface FoldCreaseRegion {
482    /**
483     * The display ID is used to identify the screen where the crease is located.
484     *
485     * @readonly
486     * @syscap SystemCapability.Window.SessionManager
487     * @since 10
488     */
489    readonly displayId: number;
490
491    /**
492     * Crease Region.
493     *
494     * @readonly
495     * @syscap SystemCapability.Window.SessionManager
496     * @since 10
497     */
498    readonly creaseRects: Array<Rect>;
499  }
500
501  /**
502   * Rectangle
503   *
504   * @interface Rect
505   * @syscap SystemCapability.WindowManager.WindowManager.Core
506   * @since 9
507   */
508  interface Rect {
509    /**
510     * The X-axis coordinate of the upper left vertex of the rectangle, in pixels.
511     *
512     * @syscap SystemCapability.WindowManager.WindowManager.Core
513     * @since 9
514     */
515    left: number;
516
517    /**
518     * The Y-axis coordinate of the upper left vertex of the rectangle, in pixels.
519     *
520     * @syscap SystemCapability.WindowManager.WindowManager.Core
521     * @since 9
522     */
523    top: number;
524
525    /**
526     * Width of the rectangle, in pixels.
527     *
528     * @syscap SystemCapability.WindowManager.WindowManager.Core
529     * @since 9
530     */
531    width: number;
532
533    /**
534     * Height of the rectangle, in pixels.
535     *
536     * @syscap SystemCapability.WindowManager.WindowManager.Core
537     * @since 9
538     */
539    height: number;
540  }
541
542  /**
543   * Curved area rects of the waterfall display.
544   *
545   * @interface WaterfallDisplayAreaRects
546   * @syscap SystemCapability.WindowManager.WindowManager.Core
547   * @since 9
548   */
549  interface WaterfallDisplayAreaRects {
550    /**
551     * Indicates the size of left side curved area of the waterfall screen.
552     *
553     * @syscap SystemCapability.WindowManager.WindowManager.Core
554     * @since 9
555     */
556    readonly left: Rect;
557
558    /**
559     * Indicates the size of right side curved area of the waterfall screen.
560     *
561     * @syscap SystemCapability.WindowManager.WindowManager.Core
562     * @since 9
563     */
564    readonly right: Rect;
565
566    /**
567     * Indicates the size of top side curved area of the waterfall screen.
568     *
569     * @syscap SystemCapability.WindowManager.WindowManager.Core
570     * @since 9
571     */
572    readonly top: Rect;
573
574    /**
575     * Indicates the size of bottom side curved area of the waterfall screen.
576     *
577     * @syscap SystemCapability.WindowManager.WindowManager.Core
578     * @since 9
579     */
580    readonly bottom: Rect;
581  }
582
583  /**
584   * Cutout information of the display.
585   *
586   * @interface CutoutInfo
587   * @syscap SystemCapability.WindowManager.WindowManager.Core
588   * @since 9
589   */
590  interface CutoutInfo {
591    /**
592     * Bounding rectangles of the cutout areas of the display.
593     *
594     * @syscap SystemCapability.WindowManager.WindowManager.Core
595     * @since 9
596     */
597    readonly boundingRects: Array<Rect>;
598
599    /**
600     * Rectangles of curved parts on each side of a waterfall display.
601     *
602     * @syscap SystemCapability.WindowManager.WindowManager.Core
603     * @since 9
604     */
605    readonly waterfallDisplayAreaRects: WaterfallDisplayAreaRects;
606  }
607
608  /**
609   * Define properties of the display. They cannot be updated automatically.
610   *
611   * @interface Display
612   * @syscap SystemCapability.WindowManager.WindowManager.Core
613   * @since 7
614   */
615  /**
616   * Define properties of the display. They cannot be updated automatically.
617   *
618   * @interface Display
619   * @syscap SystemCapability.WindowManager.WindowManager.Core
620   * @crossplatform
621   * @since 10
622   */
623  interface Display {
624    /**
625     * Display ID.
626     *
627     * @syscap SystemCapability.WindowManager.WindowManager.Core
628     * @since 7
629     */
630    /**
631     * Display ID.
632     *
633     * @syscap SystemCapability.WindowManager.WindowManager.Core
634     * @crossplatform
635     * @since 10
636     */
637    id: number;
638
639    /**
640     * Display name.
641     *
642     * @syscap SystemCapability.WindowManager.WindowManager.Core
643     * @since 7
644     */
645    name: string;
646
647    /**
648     * The display is alive.
649     *
650     * @syscap SystemCapability.WindowManager.WindowManager.Core
651     * @since 7
652     */
653    alive: boolean;
654
655    /**
656     * The state of display.
657     *
658     * @syscap SystemCapability.WindowManager.WindowManager.Core
659     * @since 7
660     */
661    state: DisplayState;
662
663    /**
664     * Refresh rate, in Hz.
665     *
666     * @syscap SystemCapability.WindowManager.WindowManager.Core
667     * @since 7
668     */
669    refreshRate: number;
670
671    /**
672     * Rotation degrees of the display.
673     *
674     * @syscap SystemCapability.WindowManager.WindowManager.Core
675     * @since 7
676     */
677    rotation: number;
678
679    /**
680     * Display width, in pixels.
681     *
682     * @syscap SystemCapability.WindowManager.WindowManager.Core
683     * @since 7
684     */
685    /**
686     * Display width, in pixels.
687     *
688     * @syscap SystemCapability.WindowManager.WindowManager.Core
689     * @crossplatform
690     * @since 10
691     */
692    width: number;
693
694    /**
695     * Display height, in pixels.
696     *
697     * @syscap SystemCapability.WindowManager.WindowManager.Core
698     * @since 7
699     */
700    /**
701     * Display height, in pixels.
702     *
703     * @syscap SystemCapability.WindowManager.WindowManager.Core
704     * @crossplatform
705     * @since 10
706     */
707    height: number;
708
709    /**
710     * Display resolution.
711     *
712     * @syscap SystemCapability.WindowManager.WindowManager.Core
713     * @since 7
714     */
715    densityDPI: number;
716
717    /**
718     * Display orientation.
719     *
720     * @syscap SystemCapability.WindowManager.WindowManager.Core
721     * @crossplatform
722     * @since 10
723     */
724    orientation: Orientation;
725
726    /**
727     * Display density, in pixels. The value for a low-resolution display is 1.0.
728     *
729     * @syscap SystemCapability.WindowManager.WindowManager.Core
730     * @since 7
731     */
732    densityPixels: number;
733
734    /**
735     * Text scale density of the display.
736     *
737     * @syscap SystemCapability.WindowManager.WindowManager.Core
738     * @since 7
739     */
740    scaledDensity: number;
741
742    /**
743     * DPI on the x-axis.
744     *
745     * @syscap SystemCapability.WindowManager.WindowManager.Core
746     * @since 7
747     */
748    xDPI: number;
749
750    /**
751     * DPI on the y-axis.
752     *
753     * @syscap SystemCapability.WindowManager.WindowManager.Core
754     * @since 7
755     */
756    yDPI: number;
757
758    /**
759     * Obtain the cutout info of the display.
760     *
761     * @param { AsyncCallback<CutoutInfo> } callback
762     * @throws { BusinessError } 1400001 - Invalid display or screen.
763     * @syscap SystemCapability.WindowManager.WindowManager.Core
764     * @since 9
765     */
766    getCutoutInfo(callback: AsyncCallback<CutoutInfo>): void;
767
768    /**
769     * Obtain the cutout info of the display.
770     *
771     * @returns { Promise<CutoutInfo> }
772     * @throws { BusinessError } 1400001 - Invalid display or screen.
773     * @syscap SystemCapability.WindowManager.WindowManager.Core
774     * @since 9
775     */
776    getCutoutInfo(): Promise<CutoutInfo>;
777  }
778}
779
780export default display;
781