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 * Obtain the default display. 26 * @since 7 27 * @deprecated since 9 28 * @useinstead ohos.display#getDefaultDisplaySync 29 */ 30 function getDefaultDisplay(callback: AsyncCallback<Display>): void; 31 32 /** 33 * Obtain the default display. 34 * @since 7 35 * @deprecated since 9 36 * @useinstead ohos.display#getDefaultDisplaySync 37 */ 38 function getDefaultDisplay(): Promise<Display>; 39 40 /** 41 * Obtain the default display. 42 * @throws {BusinessError} 1400001 - Invalid display or screen. 43 * @since 9 44 */ 45 function getDefaultDisplaySync(): Display; 46 47 /** 48 * Obtain all displays. 49 * @since 7 50 * @deprecated since 9 51 * @useinstead ohos.display#getAllDisplays 52 */ 53 function getAllDisplay(callback: AsyncCallback<Array<Display>>): void; 54 55 /** 56 * Obtain all displays. 57 * @since 7 58 * @deprecated since 9 59 * @useinstead ohos.display#getAllDisplays 60 */ 61 function getAllDisplay(): Promise<Array<Display>>; 62 63 /** 64 * Obtain all displays. 65 * @throws {BusinessError} 1400001 - Invalid display or screen. 66 * @since 9 67 */ 68 function getAllDisplays(callback: AsyncCallback<Array<Display>>): void; 69 70 /** 71 * Obtain all displays. 72 * @throws {BusinessError} 1400001 - Invalid display or screen. 73 * @since 9 74 */ 75 function getAllDisplays(): Promise<Array<Display>>; 76 77 /** 78 * Check whether there is a privacy window on the current display. 79 * @param displayId Display id to query 80 * @throws {BusinessError} 401 - Parameter error. 81 * @throws {BusinessError} 1400003 - This display manager service works abnormally. 82 * @systemapi Hide this for inner system use. 83 * @since 9 84 */ 85 function hasPrivateWindow(displayId: number): boolean; 86 87 /** 88 * Register the callback for display changes. 89 * @param type: type of callback 90 * @since 7 91 * @throws {BusinessError} 401 - Parameter error. 92 */ 93 function on(type: 'add' | 'remove' | 'change', callback: Callback<number>): void; 94 95 /** 96 * Unregister the callback for display changes. 97 * @param type: type of callback 98 * @since 7 99 * @throws {BusinessError} 401 - Parameter error. 100 */ 101 function off(type: 'add' | 'remove' | 'change', callback?: Callback<number>): void; 102 103 /** 104 * Enumerates the display states. 105 * @syscap SystemCapability.WindowManager.WindowManager.Core 106 * @since 7 107 */ 108 enum DisplayState { 109 /** 110 * Unknown. 111 */ 112 STATE_UNKNOWN = 0, 113 /** 114 * Screen off. 115 */ 116 STATE_OFF, 117 /** 118 * Screen on. 119 */ 120 STATE_ON, 121 /** 122 * Doze, but it will update for some important system messages. 123 */ 124 STATE_DOZE, 125 /** 126 * Doze and not update. 127 */ 128 STATE_DOZE_SUSPEND, 129 /** 130 * VR node. 131 */ 132 STATE_VR, 133 /** 134 * Screen on and not update. 135 */ 136 STATE_ON_SUSPEND, 137 } 138 139 /** 140 * Rectangle 141 * @syscap SystemCapability.WindowManager.WindowManager.Core 142 * @since 9 143 */ 144 interface Rect { 145 /** 146 * The X-axis coordinate of the upper left vertex of the rectangle, in pixels. 147 * @since 9 148 */ 149 left: number; 150 151 /** 152 * The Y-axis coordinate of the upper left vertex of the rectangle, in pixels. 153 * @since 9 154 */ 155 top: number; 156 157 /** 158 * Width of the rectangle, in pixels. 159 * @since 9 160 */ 161 width: number; 162 163 /** 164 * Height of the rectangle, in pixels. 165 * @since 9 166 */ 167 height: number; 168 } 169 170 /** 171 * Curved area rects of the waterfall display. 172 * @syscap SystemCapability.WindowManager.WindowManager.Core 173 * @since 9 174 */ 175 interface WaterfallDisplayAreaRects { 176 /** 177 * Indicates the size of left side curved area of the waterfall screen. 178 * @since 9 179 */ 180 readonly left: Rect; 181 182 /** 183 * Indicates the size of right side curved area of the waterfall screen. 184 * @since 9 185 */ 186 readonly right: Rect; 187 188 /** 189 * Indicates the size of top side curved area of the waterfall screen. 190 * @since 9 191 */ 192 readonly top: Rect; 193 194 /** 195 * Indicates the size of bottom side curved area of the waterfall screen. 196 * @since 9 197 */ 198 readonly bottom: Rect; 199 } 200 201 /** 202 * Cutout information of the display. 203 * @syscap SystemCapability.WindowManager.WindowManager.Core 204 * @since 9 205 */ 206 interface CutoutInfo { 207 /** 208 * Bounding rectangles of the cutout areas of the display. 209 * @since 9 210 */ 211 readonly boundingRects: Array<Rect>; 212 213 /** 214 * Rectangles of curved parts on each side of a waterfall display. 215 * @since 9 216 */ 217 readonly waterfallDisplayAreaRects: WaterfallDisplayAreaRects; 218 } 219 220 /** 221 * Define properties of the display. They cannot be updated automatically. 222 * @syscap SystemCapability.WindowManager.WindowManager.Core 223 * @since 7 224 */ 225 interface Display { 226 /** 227 * Display ID. 228 */ 229 id: number; 230 231 /** 232 * Display name. 233 */ 234 name: string; 235 236 /** 237 * The display is alive. 238 */ 239 alive: boolean; 240 241 /** 242 * The state of display. 243 */ 244 state: DisplayState; 245 246 /** 247 * Refresh rate, in Hz. 248 */ 249 refreshRate: number; 250 251 /** 252 * Rotation degrees of the display. 253 */ 254 rotation: number; 255 256 /** 257 * Display width, in pixels. 258 */ 259 width: number; 260 261 /** 262 * Display height, in pixels. 263 */ 264 height: number; 265 266 /** 267 * Display resolution. 268 */ 269 densityDPI: number; 270 271 /** 272 * Display density, in pixels. The value for a low-resolution display is 1.0. 273 */ 274 densityPixels: number; 275 276 /** 277 * Text scale density of the display. 278 */ 279 scaledDensity: number; 280 281 /** 282 * DPI on the x-axis. 283 */ 284 xDPI: number; 285 286 /** 287 * DPI on the y-axis. 288 */ 289 yDPI: number; 290 291 /** 292 * Obtain the cutout info of the display. 293 * @throws {BusinessError} 1400001 - Invalid display or screen. 294 * @since 9 295 */ 296 getCutoutInfo(callback: AsyncCallback<CutoutInfo>): void; 297 298 /** 299 * Obtain the cutout info of the display. 300 * @throws {BusinessError} 1400001 - Invalid display or screen. 301 * @since 9 302 */ 303 getCutoutInfo(): Promise<CutoutInfo>; 304 } 305} 306 307export default display;