• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2* Copyright (c) 2022 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 screen manager
20 * @syscap SystemCapability.WindowManager.WindowManager.Core
21 * @systemapi Hide this for inner system use.
22 * @since 9
23 */
24declare namespace screen {
25  /**
26   * get all screen
27   * @since 9
28   */
29  function getAllScreens(callback: AsyncCallback<Array<Screen>>): void;
30  function getAllScreens(): Promise<Array<Screen>>;
31
32  /**
33   * Register the callback for screen changes.
34   * @param eventType: type of callback
35   * @since 9
36   */
37  function on(eventType: 'connect' | 'disconnect' | 'change', callback: Callback<number>): void;
38
39  /**
40   * Unregister the callback for screen changes.
41   * @param eventType: type of callback
42   * @since 9
43   */
44  function off(eventType: 'connect' | 'disconnect' | 'change', callback?: Callback<number>): void;
45
46  /**
47   * make screens as expand-screen
48   * @throws DM_ERROR_INVALID_PARAM If param is not valid
49   * @since 9
50   */
51  function makeExpand(options:Array<ExpandOption>, callback: AsyncCallback<number>): void;
52  function makeExpand(options:Array<ExpandOption>): Promise<number>;
53
54  /**
55   * make screens as mirror-screen
56   * @throws DM_ERROR_INVALID_PARAM If param is not valid
57   * @since 9
58   */
59  function makeMirror(mainScreen:number, mirrorScreen:Array<number>, callback: AsyncCallback<number>): void;
60  function makeMirror(mainScreen:number, mirrorScreen:Array<number>): Promise<number>;
61
62  /**
63   * Create virtual screen.
64   * @param options Indicates the options of the virtual screen.
65   * @permission ohos.permission.CAPTURE_SCREEN. if VirtualScreenOption.surfaceId is valid,
66   *             this permission is necessary.
67   * @throws DM_ERROR_INVALID_PARAM If param is not valid
68   * @since 9
69   */
70  function createVirtualScreen(options:VirtualScreenOption, callback: AsyncCallback<Screen>): void;
71  function createVirtualScreen(options:VirtualScreenOption): Promise<Screen>;
72
73  /**
74   * Destroy virtual screen.
75   * @param screenId Indicates the screen id of the virtual screen.
76   * @throws DM_ERROR_INVALID_PARAM If param is not valid
77   * @since 9
78   */
79  function destroyVirtualScreen(screenId:number, callback: AsyncCallback<void>): void;
80  function destroyVirtualScreen(screenId:number): Promise<void>;
81
82  /**
83   * Set surface for the virtual screen.
84   * @param screenId Indicates the screen id of the virtual screen.
85   * @param surfaceId Indicates the surface id.
86   * @permission ohos.permission.CAPTURE_SCREEN
87   * @throws DM_ERROR_INVALID_PARAM If param is not valid
88   * @since 9
89   */
90  function setVirtualScreenSurface(screenId:number, surfaceId: string, callback: AsyncCallback<void>): void;
91  function setVirtualScreenSurface(screenId:number, surfaceId: string): Promise<void>;
92
93  /**
94   * Get screen rotation lock status.
95   * @since 9
96   */
97  function isScreenRotationLocked(callback: AsyncCallback<boolean>): void;
98  function isScreenRotationLocked(): Promise<boolean>;
99
100  /**
101   * Set screen rotation lock status.
102   * @param isLocked Indicates whether the screen rotation switch is locked.
103   * @throws DM_ERROR_INVALID_PARAM If param is not valid
104   * @since 9
105   */
106  function setScreenRotationLocked(isLocked:boolean, callback: AsyncCallback<void>): void;
107  function setScreenRotationLocked(isLocked:boolean): Promise<void>;
108
109  /**
110   * the parameter of making expand screen
111   * @syscap SystemCapability.WindowManager.WindowManager.Core
112   * @since 9
113   */
114  interface ExpandOption {
115    /**
116     * screen id
117     */
118    screenId: number;
119
120    /**
121     * the start coordinate X of the screen origin
122     */
123    startX: number;
124
125    /**
126     * the start coordinate Y of the screen origin
127     */
128    startY: number;
129  }
130
131  /**
132   * The parameter for creating virtual screen.
133   * @syscap SystemCapability.WindowManager.WindowManager.Core
134   * @since 9
135   */
136  interface VirtualScreenOption {
137    /**
138     * Indicates the name of the virtual screen.
139     */
140    name: string
141
142    /**
143     * Indicates the width of the virtual screen.
144     */
145    width: number
146
147    /**
148     * Indicates the height of the virtual screen.
149     */
150    height: number
151
152    /**
153     * Indicates the density of the virtual screen.
154     */
155    density: number
156
157    /**
158     * Indicates the surface id of the virtual screen.
159     */
160    surfaceId: string
161  }
162
163  /**
164   * interface for screen
165   * @syscap SystemCapability.WindowManager.WindowManager.Core
166   * @since 9
167   */
168  interface Screen {
169    /**
170     * screen id
171     */
172    readonly id: number;
173
174    /**
175     * group id
176     */
177    readonly parent: number;
178
179    /**
180     * mode supported by the screen
181     */
182    readonly supportedModeInfo: Array<ScreenModeInfo>;
183
184    /**
185     * currently active mode
186     */
187    readonly activeModeIndex: number;
188
189    /**
190     * orientation of the screen
191     */
192    readonly orientation: Orientation;
193
194    /**
195     * set the orientation of the screen
196     * @throws DM_ERROR_INVALID_PARAM If param is not valid
197     * @since 9
198     */
199    setOrientation(orientation: Orientation, callback: AsyncCallback<void>): void;
200    setOrientation(orientation: Orientation): Promise<void>;
201
202    /**
203     * active the mode
204     * @throws DM_ERROR_INVALID_PARAM If param is not valid
205     */
206    setScreenActiveMode(modeIndex: number, callback: AsyncCallback<void>): void;
207    setScreenActiveMode(modeIndex: number): Promise<void>;
208
209    /**
210     * set display density of the screen
211     * @throws DM_ERROR_INVALID_PARAM If param is not valid
212     */
213    setDensityDpi(densityDpi: number, callback: AsyncCallback<void>): void;
214    setDensityDpi(densityDpi: number): Promise<void>;
215  }
216
217  /**
218   * screen orientation
219   * @syscap SystemCapability.WindowManager.WindowManager.Core
220   * @since 9
221   */
222  enum Orientation {
223    UNSPECIFIED = 0,
224    VERTICAL = 1,
225    HORIZONTAL = 2,
226    REVERSE_VERTICAL = 3,
227    REVERSE_HORIZONTAL = 4,
228  }
229
230  /**
231   * the information of the screen
232   * @syscap SystemCapability.WindowManager.WindowManager.Core
233   * @since 9
234   */
235  interface ScreenModeInfo {
236    id: number;
237    width: number;
238    height: number;
239    refreshRate: number;
240  }
241}
242
243export default screen;
244