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