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