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