1/* 2 * Copyright (c) 2023-2024 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 16/** 17 * @file 18 * @kit ArkUI 19 */ 20 21 22import { Callback } from './@ohos.base'; 23import window from './@ohos.window'; 24/** 25 * uiExtensionHost. 26 * 27 * @namespace uiExtensionHost 28 * @syscap SystemCapability.ArkUI.ArkUI.Full 29 * @systemapi 30 * @since 11 31 */ 32 declare namespace uiExtensionHost { 33 /** 34 * Window Info 35 * 36 * @typedef WindowInfo 37 * @syscap SystemCapability.ArkUI.ArkUI.Full 38 * @systemapi 39 * @since 16 40 */ 41 export interface WindowInfo { 42 /** 43 * Type of the area. 44 * 45 * @typedef { window.AvoidAreaType } 46 * @syscap SystemCapability.ArkUI.ArkUI.Full 47 * @since 16 48 */ 49 type: window.AvoidAreaType; 50 /** 51 * Area where the window cannot be displayed. 52 * 53 * @typedef { window.AvoidArea } 54 * @syscap SystemCapability.ArkUI.ArkUI.Full 55 * @since 16 56 */ 57 area: window.AvoidArea; 58 } 59 60 /** 61 * Transition Controller 62 * 63 * @interface UIExtensionHostWindowProxy 64 * @syscap SystemCapability.ArkUI.ArkUI.Full 65 * @systemapi 66 * @since 11 67 */ 68 export interface UIExtensionHostWindowProxy { 69 /** 70 * Get the avoid area 71 * 72 * @param { window.AvoidAreaType } type - Type of the area 73 * @returns { window.AvoidArea } Area where the window cannot be displayed. 74 * @throws { BusinessError } 401 - Parameter error. 75 * @syscap SystemCapability.ArkUI.ArkUI.Full 76 * @systemapi 77 * @since 11 78 */ 79 getWindowAvoidArea(type: window.AvoidAreaType): window.AvoidArea; 80 81 /** 82 * Register the callback of avoidAreaChange 83 * 84 * @param { 'avoidAreaChange' } type - The value is fixed at 'avoidAreaChange', indicating the event of changes to the avoid area. 85 * @param { Callback<{ type: window.AvoidAreaType, area: window.AvoidArea }> } callback - Callback used to return the area. 86 * @throws { BusinessError } 401 - Parameter error. Possible causes: 87 * <br> 1. Mandatory parameters are left unspecified. 88 * <br> 2. Incorrect parameters types. 89 * <br> 3. Parameter verification failed. 90 * @syscap SystemCapability.ArkUI.ArkUI.Full 91 * @systemapi 92 * @since 11 93 */ 94 /** 95 * Register the callback of avoidAreaChange 96 * 97 * @param { 'avoidAreaChange' } type - The value is fixed at 'avoidAreaChange', indicating the event of changes to the avoid area. 98 * @param { Callback<WindowInfo> } callback - Callback used to return the area. 99 * @throws { BusinessError } 401 - Parameter error. Possible causes: 100 * <br> 1. Mandatory parameters are left unspecified. 101 * <br> 2. Incorrect parameters types. 102 * <br> 3. Parameter verification failed. 103 * @syscap SystemCapability.ArkUI.ArkUI.Full 104 * @systemapi 105 * @since 16 106 */ 107 // on(type: 'avoidAreaChange', callback: Callback<WindowInfo>): void; 108 on<T>(type: string, callback: Callback<T>):void; 109 110 /** 111 * Unregister the callback of avoidAreaChange 112 * 113 * @param { 'avoidAreaChange' } type - The value is fixed at 'avoidAreaChange', indicating the event of changes to the avoid area. 114 * @param { Callback<{ type: window.AvoidAreaType, area: window.AvoidArea }> } callback - Callback used to return the area. 115 * @throws { BusinessError } 401 - Parameter error. Possible causes: 116 * <br> 1. Mandatory parameters are left unspecified. 117 * <br> 2. Incorrect parameters types. 118 * <br> 3. Parameter verification failed. 119 * @syscap SystemCapability.ArkUI.ArkUI.Full 120 * @systemapi 121 * @since 11 122 */ 123 /** 124 * Unregister the callback of avoidAreaChange 125 * 126 * @param { 'avoidAreaChange' } type - The value is fixed at 'avoidAreaChange', indicating the event of changes to the avoid area. 127 * @param { Callback<WindowInfo> } callback - Callback used to return the area. 128 * @throws { BusinessError } 401 - Parameter error. Possible causes: 129 * <br> 1. Mandatory parameters are left unspecified. 130 * <br> 2. Incorrect parameters types. 131 * <br> 3. Parameter verification failed. 132 * @syscap SystemCapability.ArkUI.ArkUI.Full 133 * @systemapi 134 * @since 16 135 */ 136 // off(type: 'avoidAreaChange', callback?: Callback<WindowInfo>): void; 137 off<T>(type: string, callback?: Callback<T>): void; 138 139 /** 140 * Register the callback of windowSizeChange 141 * 142 * @param { 'windowSizeChange' } type - The value is fixed at 'windowSizeChange', indicating the window size change event. 143 * @param { Callback<window.Size> } callback - Callback used to return the window size. 144 * @throws { BusinessError } 401 - Parameter error. Possible causes: 145 * <br> 1. Mandatory parameters are left unspecified. 146 * <br> 2. Incorrect parameters types. 147 * <br> 3. Parameter verification failed. 148 * @syscap SystemCapability.ArkUI.ArkUI.Full 149 * @systemapi 150 * @since 11 151 */ 152 // on(type: 'windowSizeChange', callback: Callback<window.Size>): void; 153 154 /** 155 * Unregister the callback of windowSizeChange 156 * 157 * @param { 'windowSizeChange' } type - The value is fixed at 'windowSizeChange', indicating the window size change event. 158 * @param { Callback<window.Size> } callback - Callback used to return the window size. 159 * @throws { BusinessError } 401 - Parameter error. Possible causes: 160 * <br> 1. Mandatory parameters are left unspecified. 161 * <br> 2. Incorrect parameters types. 162 * <br> 3. Parameter verification failed. 163 * @syscap SystemCapability.ArkUI.ArkUI.Full 164 * @systemapi 165 * @since 11 166 */ 167 // off(type: 'windowSizeChange', callback?: Callback<window.Size>): void; 168 169 /** 170 * The properties of the UIExtension window 171 * 172 * @type { UIExtensionHostWindowProxyProperties } 173 * @syscap SystemCapability.ArkUI.ArkUI.Full 174 * @systemapi 175 * @since 11 176 */ 177 properties: UIExtensionHostWindowProxyProperties; 178 179 /** 180 * Hide the non-secure windows 181 * 182 * @param { boolean } shouldHide - Hide the non-secure windows if true, otherwise means the opposite. 183 * @returns { Promise<void> } - The promise returned by the function. 184 * @throws { BusinessError } 401 - Parameter error. Possible causes: 185 * <br> 1. Mandatory parameters are left unspecified. 186 * <br> 2. Incorrect parameters types. 187 * <br> 3. Parameter verification failed. 188 * @syscap SystemCapability.ArkUI.ArkUI.Full 189 * @systemapi 190 * @since 11 191 */ 192 /** 193 * Hide the non-secure windows. 194 * When called by modal UIExtension and shouldHide == false, the "ohos.permission.ALLOW_SHOW_NON_SECURE_WINDOWS" permission is required. 195 * 196 * @permission ohos.permission.ALLOW_SHOW_NON_SECURE_WINDOWS 197 * @param { boolean } shouldHide - Hide the non-secure windows if true, otherwise means the opposite. 198 * @returns { Promise<void> } - The promise returned by the function. 199 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 200 * @throws { BusinessError } 401 - Parameter error. Possible causes: 201 * <br> 1. Mandatory parameters are left unspecified. 202 * <br> 2. Incorrect parameters types. 203 * <br> 3. Parameter verification failed. 204 * @throws { BusinessError } 1300002 - Abnormal state. Possible causes: 205 * <br> 1. Permission denied. Interface caller does not have permission "ohos.permission.ALLOW_SHOW_NON_SECURE_WINDOWS". 206 * <br> 2. The UIExtension window proxy is abnormal. 207 * @throws { BusinessError } 1300003 - This window manager service works abnormally. 208 * @syscap SystemCapability.ArkUI.ArkUI.Full 209 * @systemapi 210 * @since 12 211 */ 212 hideNonSecureWindows(shouldHide: boolean): Promise<void>; 213 214 /** 215 * Create sub window. 216 * 217 * @param { string } name - window name of sub window 218 * @param { window.SubWindowOptions } subWindowOptions - options of sub window creation 219 * @returns { Promise<window.Window> } Promise used to return the subwindow. 220 * @throws { BusinessError } 401 - Parameter error. Possible causes: 221 * <br> 1. Mandatory parameters are left unspecified. 222 * <br> 2. Incorrect parameters types. 223 * <br> 3. Parameter verification failed. 224 * @throws { BusinessError } 801 - Capability not supported. Failed to call the API due to limited device capabilities. 225 * @throws { BusinessError } 1300002 - This window state is abnormal. 226 * @throws { BusinessError } 1300005 - This window proxy is abnormal. 227 * @syscap SystemCapability.ArkUI.ArkUI.Full 228 * @systemapi 229 * @StageModelOnly 230 * @since 12 231 */ 232 createSubWindowWithOptions(name: string, subWindowOptions: window.SubWindowOptions): Promise<window.Window>; 233 234 /** 235 * Set the watermark flag on the UIExtension window 236 * 237 * @param { boolean } enable - Add water mark flag to the UIExtension window if true, or remove flag if false 238 * @returns { Promise<void> } - The promise returned by the function 239 * @throws { BusinessError } 1300002 - The UIExtension window proxy is abnormal. 240 * @throws { BusinessError } 1300003 - This window manager service works abnormally. 241 * @throws { BusinessError } 1300008 - The display device is abnormal. 242 * @syscap SystemCapability.ArkUI.ArkUI.Full 243 * @systemapi 244 * @since 12 245 */ 246 setWaterMarkFlag(enable: boolean): Promise<void>; 247 248 /** 249 * Hide the display content when snapshot. 250 * 251 * @param { boolean } shouldHide - Hide the display content of UIExtensionAbility when the host application takes snapshots if true, 252 * otherwise means the opposite. 253 * @returns { Promise<void> } - The promise returned by the function. 254 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 255 * @throws { BusinessError } 401 - Parameter error. Possible causes: 256 * <br> 1. Mandatory parameters are left unspecified. 257 * <br> 2. Incorrect parameters types. 258 * <br> 3. Parameter verification failed. 259 * @throws { BusinessError } 1300002 - Abnormal state. Possible causes: 260 * <br> 1. The UIExtension window proxy is abnormal. 261 * <br> 2. Not the UIExtensionAbility process calling. 262 * @syscap SystemCapability.ArkUI.ArkUI.Full 263 * @systemapi 264 * @since 13 265 */ 266 hidePrivacyContentForHost(shouldHide: boolean): Promise<void>; 267 } 268 269 /** 270 * Properties of UIExtension window 271 * 272 * @interface UIExtensionHostWindowProxyProperties 273 * @syscap SystemCapability.ArkUI.ArkUI.Full 274 * @systemapi 275 * @since 11 276 */ 277 export interface UIExtensionHostWindowProxyProperties { 278 /** 279 * The position and size of the UIExtension window 280 * 281 * @type { window.Rect } 282 * @syscap SystemCapability.ArkUI.ArkUI.Full 283 * @systemapi 284 * @since 11 285 */ 286 uiExtensionHostWindowProxyRect: window.Rect; 287 } 288} 289export default uiExtensionHost;