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