• 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 { AsyncCallback, Callback } from './basic';
17
18/**
19 * interface of display manager
20 * @syscap SystemCapability.WindowManager.WindowManager.Core
21 * @since 7
22 */
23declare namespace display {
24  /**
25   * get the default display
26   * @since 7
27   */
28  function getDefaultDisplay(callback: AsyncCallback<Display>): void;
29
30  /**
31   * get the default display
32   * @since 7
33   */
34  function getDefaultDisplay(): Promise<Display>;
35
36  /**
37   * get all displays
38   * @since 7
39   */
40  function getAllDisplay(callback: AsyncCallback<Array<Display>>): void;
41
42  /**
43   * get all displays
44   * @since 7
45   */
46  function getAllDisplay(): Promise<Array<Display>>;
47
48  /**
49   * register the callback of display change
50   * @param type: type of callback
51   * @since 7
52   */
53  function on(type: 'add' | 'remove' | 'change', callback: Callback<number>): void;
54
55  /**
56   * unregister the callback of display change
57   * @param type: type of callback
58   * @since 7
59   */
60  function off(type: 'add' | 'remove' | 'change', callback?: Callback<number>): void;
61
62  /**
63   * the state of display
64   * @syscap SystemCapability.WindowManager.WindowManager.Core
65   * @since 7
66   */
67  enum DisplayState {
68    /**
69     * unknown
70     */
71    STATE_UNKNOWN = 0,
72    /**
73     * screen off
74     */
75    STATE_OFF,
76    /**
77     * screen on
78     */
79    STATE_ON,
80    /**
81     * doze, but it will update for some important system messages
82     */
83    STATE_DOZE,
84    /**
85     * doze and not update
86     */
87    STATE_DOZE_SUSPEND,
88    /**
89     * VR node
90     */
91    STATE_VR,
92    /**
93     * screen on and not update
94     */
95    STATE_ON_SUSPEND,
96  }
97
98  /**
99   * Properties of display, it couldn't update automatically
100   * @syscap SystemCapability.WindowManager.WindowManager.Core
101   * @since 7
102   */
103  interface Display {
104    /**
105     * display id
106     */
107    id: number;
108
109    /**
110     * display name
111     */
112    name: string;
113
114    /**
115     * the display is alive
116     */
117    alive: boolean;
118
119    /**
120     * the state of display
121     */
122    state: DisplayState;
123
124    /**
125     * refresh rate, unit: Hz
126     */
127    refreshRate: number;
128
129    /**
130     * the rotation degrees of the display
131     */
132    rotation: number;
133
134    /**
135     * the width of display, unit: pixel
136     */
137    width: number;
138
139    /**
140     * the height of display, unit: pixel
141     */
142    height: number;
143
144    /**
145     * indicates the display resolution.
146     */
147    densityDPI: number;
148
149    /**
150     * indicates the display density in pixels. The value of a low-resolution display is 1.0
151     */
152    densityPixels: number;
153
154    /**
155     * indicates the text scale density of a display.
156     */
157    scaledDensity: number;
158
159    /**
160     * the DPI on X-axis.
161     */
162    xDPI: number;
163
164    /**
165     * the DPI on Y-axis.
166     */
167    yDPI: number;
168  }
169}
170
171export default display;