161847f8eSopenharmony_ci/* 261847f8eSopenharmony_ci * Copyright (c) 2023-2024 Huawei Device Co., Ltd. 361847f8eSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 461847f8eSopenharmony_ci * you may not use this file except in compliance with the License. 561847f8eSopenharmony_ci * You may obtain a copy of the License at 661847f8eSopenharmony_ci * 761847f8eSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 861847f8eSopenharmony_ci * 961847f8eSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1061847f8eSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1161847f8eSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1261847f8eSopenharmony_ci * See the License for the specific language governing permissions and 1361847f8eSopenharmony_ci * limitations under the License. 1461847f8eSopenharmony_ci */ 1561847f8eSopenharmony_ci 1661847f8eSopenharmony_ci/** 1761847f8eSopenharmony_ci * @file 1861847f8eSopenharmony_ci * @kit ArkUI 1961847f8eSopenharmony_ci */ 2061847f8eSopenharmony_ci 2161847f8eSopenharmony_ci 2261847f8eSopenharmony_ciimport { Callback } from './@ohos.base'; 2361847f8eSopenharmony_ciimport window from './@ohos.window'; 2461847f8eSopenharmony_ci/** 2561847f8eSopenharmony_ci * uiExtensionHost. 2661847f8eSopenharmony_ci * 2761847f8eSopenharmony_ci * @namespace uiExtensionHost 2861847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 2961847f8eSopenharmony_ci * @systemapi 3061847f8eSopenharmony_ci * @since 11 3161847f8eSopenharmony_ci */ 3261847f8eSopenharmony_cideclare namespace uiExtensionHost { 3361847f8eSopenharmony_ci /** 3461847f8eSopenharmony_ci * Transition Controller 3561847f8eSopenharmony_ci * 3661847f8eSopenharmony_ci * @interface UIExtensionHostWindowProxy 3761847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 3861847f8eSopenharmony_ci * @systemapi 3961847f8eSopenharmony_ci * @since 11 4061847f8eSopenharmony_ci */ 4161847f8eSopenharmony_ci interface UIExtensionHostWindowProxy { 4261847f8eSopenharmony_ci /** 4361847f8eSopenharmony_ci * Get the avoid area 4461847f8eSopenharmony_ci * 4561847f8eSopenharmony_ci * @param { window.AvoidAreaType } type - Type of the area 4661847f8eSopenharmony_ci * @returns { window.AvoidArea } Area where the window cannot be displayed. 4761847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 4861847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 4961847f8eSopenharmony_ci * @systemapi 5061847f8eSopenharmony_ci * @since 11 5161847f8eSopenharmony_ci */ 5261847f8eSopenharmony_ci getWindowAvoidArea(type: window.AvoidAreaType): window.AvoidArea; 5361847f8eSopenharmony_ci 5461847f8eSopenharmony_ci /** 5561847f8eSopenharmony_ci * Register the callback of avoidAreaChange 5661847f8eSopenharmony_ci * 5761847f8eSopenharmony_ci * @param { 'avoidAreaChange' } type - The value is fixed at 'avoidAreaChange', indicating the event of changes to the avoid area. 5861847f8eSopenharmony_ci * @param { Callback<{ type: window.AvoidAreaType, area: window.AvoidArea }> } callback - Callback used to return the area. 5961847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 6061847f8eSopenharmony_ci * <br> 1. Mandatory parameters are left unspecified. 6161847f8eSopenharmony_ci * <br> 2. Incorrect parameters types. 6261847f8eSopenharmony_ci * <br> 3. Parameter verification failed. 6361847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 6461847f8eSopenharmony_ci * @systemapi 6561847f8eSopenharmony_ci * @since 11 6661847f8eSopenharmony_ci */ 6761847f8eSopenharmony_ci on(type: 'avoidAreaChange', callback: Callback<{ type: window.AvoidAreaType, area: window.AvoidArea }>): void; 6861847f8eSopenharmony_ci 6961847f8eSopenharmony_ci /** 7061847f8eSopenharmony_ci * Unregister the callback of avoidAreaChange 7161847f8eSopenharmony_ci * 7261847f8eSopenharmony_ci * @param { 'avoidAreaChange' } type - The value is fixed at 'avoidAreaChange', indicating the event of changes to the avoid area. 7361847f8eSopenharmony_ci * @param { Callback<{ type: window.AvoidAreaType, area: window.AvoidArea }> } callback - Callback used to return the area. 7461847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 7561847f8eSopenharmony_ci * <br> 1. Mandatory parameters are left unspecified. 7661847f8eSopenharmony_ci * <br> 2. Incorrect parameters types. 7761847f8eSopenharmony_ci * <br> 3. Parameter verification failed. 7861847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 7961847f8eSopenharmony_ci * @systemapi 8061847f8eSopenharmony_ci * @since 11 8161847f8eSopenharmony_ci */ 8261847f8eSopenharmony_ci off(type: 'avoidAreaChange', callback?: Callback<{ type: window.AvoidAreaType, area: window.AvoidArea }>): void; 8361847f8eSopenharmony_ci 8461847f8eSopenharmony_ci /** 8561847f8eSopenharmony_ci * Register the callback of windowSizeChange 8661847f8eSopenharmony_ci * 8761847f8eSopenharmony_ci * @param { 'windowSizeChange' } type - The value is fixed at 'windowSizeChange', indicating the window size change event. 8861847f8eSopenharmony_ci * @param { Callback<window.Size> } callback - Callback used to return the window size. 8961847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 9061847f8eSopenharmony_ci * <br> 1. Mandatory parameters are left unspecified. 9161847f8eSopenharmony_ci * <br> 2. Incorrect parameters types. 9261847f8eSopenharmony_ci * <br> 3. Parameter verification failed. 9361847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 9461847f8eSopenharmony_ci * @systemapi 9561847f8eSopenharmony_ci * @since 11 9661847f8eSopenharmony_ci */ 9761847f8eSopenharmony_ci on(type: 'windowSizeChange', callback: Callback<window.Size>): void; 9861847f8eSopenharmony_ci 9961847f8eSopenharmony_ci /** 10061847f8eSopenharmony_ci * Unregister the callback of windowSizeChange 10161847f8eSopenharmony_ci * 10261847f8eSopenharmony_ci * @param { 'windowSizeChange' } type - The value is fixed at 'windowSizeChange', indicating the window size change event. 10361847f8eSopenharmony_ci * @param { Callback<window.Size> } callback - Callback used to return the window size. 10461847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 10561847f8eSopenharmony_ci * <br> 1. Mandatory parameters are left unspecified. 10661847f8eSopenharmony_ci * <br> 2. Incorrect parameters types. 10761847f8eSopenharmony_ci * <br> 3. Parameter verification failed. 10861847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 10961847f8eSopenharmony_ci * @systemapi 11061847f8eSopenharmony_ci * @since 11 11161847f8eSopenharmony_ci */ 11261847f8eSopenharmony_ci off(type: 'windowSizeChange', callback?: Callback<window.Size>): void; 11361847f8eSopenharmony_ci 11461847f8eSopenharmony_ci /** 11561847f8eSopenharmony_ci * The properties of the UIExtension window 11661847f8eSopenharmony_ci * 11761847f8eSopenharmony_ci * @type { UIExtensionHostWindowProxyProperties } 11861847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 11961847f8eSopenharmony_ci * @systemapi 12061847f8eSopenharmony_ci * @since 11 12161847f8eSopenharmony_ci */ 12261847f8eSopenharmony_ci properties: UIExtensionHostWindowProxyProperties; 12361847f8eSopenharmony_ci 12461847f8eSopenharmony_ci /** 12561847f8eSopenharmony_ci * Hide the non-secure windows 12661847f8eSopenharmony_ci * 12761847f8eSopenharmony_ci * @param { boolean } shouldHide - Hide the non-secure windows if true, otherwise means the opposite. 12861847f8eSopenharmony_ci * @returns { Promise<void> } - The promise returned by the function. 12961847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 13061847f8eSopenharmony_ci * <br> 1. Mandatory parameters are left unspecified. 13161847f8eSopenharmony_ci * <br> 2. Incorrect parameters types. 13261847f8eSopenharmony_ci * <br> 3. Parameter verification failed. 13361847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 13461847f8eSopenharmony_ci * @systemapi 13561847f8eSopenharmony_ci * @since 11 13661847f8eSopenharmony_ci */ 13761847f8eSopenharmony_ci /** 13861847f8eSopenharmony_ci * Hide the non-secure windows. 13961847f8eSopenharmony_ci * When called by modal UIExtension and shouldHide == false, the "ohos.permission.ALLOW_SHOW_NON_SECURE_WINDOWS" permission is required. 14061847f8eSopenharmony_ci * 14161847f8eSopenharmony_ci * @permission ohos.permission.ALLOW_SHOW_NON_SECURE_WINDOWS 14261847f8eSopenharmony_ci * @param { boolean } shouldHide - Hide the non-secure windows if true, otherwise means the opposite. 14361847f8eSopenharmony_ci * @returns { Promise<void> } - The promise returned by the function. 14461847f8eSopenharmony_ci * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 14561847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 14661847f8eSopenharmony_ci * <br> 1. Mandatory parameters are left unspecified. 14761847f8eSopenharmony_ci * <br> 2. Incorrect parameters types. 14861847f8eSopenharmony_ci * <br> 3. Parameter verification failed. 14961847f8eSopenharmony_ci * @throws { BusinessError } 1300002 - Abnormal state. Possible causes: 15061847f8eSopenharmony_ci * <br> 1. Permission denied. Interface caller does not have permission "ohos.permission.ALLOW_SHOW_NON_SECURE_WINDOWS". 15161847f8eSopenharmony_ci * <br> 2. The UIExtension window proxy is abnormal. 15261847f8eSopenharmony_ci * @throws { BusinessError } 1300003 - This window manager service works abnormally. 15361847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 15461847f8eSopenharmony_ci * @systemapi 15561847f8eSopenharmony_ci * @since 12 15661847f8eSopenharmony_ci */ 15761847f8eSopenharmony_ci hideNonSecureWindows(shouldHide: boolean): Promise<void>; 15861847f8eSopenharmony_ci 15961847f8eSopenharmony_ci /** 16061847f8eSopenharmony_ci * Create sub window. 16161847f8eSopenharmony_ci * 16261847f8eSopenharmony_ci * @param { string } name - window name of sub window 16361847f8eSopenharmony_ci * @param { window.SubWindowOptions } subWindowOptions - options of sub window creation 16461847f8eSopenharmony_ci * @returns { Promise<window.Window> } Promise used to return the subwindow. 16561847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 16661847f8eSopenharmony_ci * <br> 1. Mandatory parameters are left unspecified. 16761847f8eSopenharmony_ci * <br> 2. Incorrect parameters types. 16861847f8eSopenharmony_ci * <br> 3. Parameter verification failed. 16961847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. Failed to call the API due to limited device capabilities. 17061847f8eSopenharmony_ci * @throws { BusinessError } 1300002 - This window state is abnormal. 17161847f8eSopenharmony_ci * @throws { BusinessError } 1300005 - This window proxy is abnormal. 17261847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 17361847f8eSopenharmony_ci * @systemapi 17461847f8eSopenharmony_ci * @StageModelOnly 17561847f8eSopenharmony_ci * @since 12 17661847f8eSopenharmony_ci */ 17761847f8eSopenharmony_ci createSubWindowWithOptions(name: string, subWindowOptions: window.SubWindowOptions): Promise<window.Window>; 17861847f8eSopenharmony_ci 17961847f8eSopenharmony_ci /** 18061847f8eSopenharmony_ci * Set the watermark flag on the UIExtension window 18161847f8eSopenharmony_ci * 18261847f8eSopenharmony_ci * @param { boolean } enable - Add water mark flag to the UIExtension window if true, or remove flag if false 18361847f8eSopenharmony_ci * @returns { Promise<void> } - The promise returned by the function 18461847f8eSopenharmony_ci * @throws { BusinessError } 1300002 - The UIExtension window proxy is abnormal. 18561847f8eSopenharmony_ci * @throws { BusinessError } 1300003 - This window manager service works abnormally. 18661847f8eSopenharmony_ci * @throws { BusinessError } 1300008 - The display device is abnormal. 18761847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 18861847f8eSopenharmony_ci * @systemapi 18961847f8eSopenharmony_ci * @since 12 19061847f8eSopenharmony_ci */ 19161847f8eSopenharmony_ci setWaterMarkFlag(enable: boolean): Promise<void>; 19261847f8eSopenharmony_ci 19361847f8eSopenharmony_ci /** 19461847f8eSopenharmony_ci * Hide the display content when snapshot. 19561847f8eSopenharmony_ci * 19661847f8eSopenharmony_ci * @param { boolean } shouldHide - Hide the display content of UIExtensionAbility when the host application takes snapshots if true, 19761847f8eSopenharmony_ci * otherwise means the opposite. 19861847f8eSopenharmony_ci * @returns { Promise<void> } - The promise returned by the function. 19961847f8eSopenharmony_ci * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 20061847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 20161847f8eSopenharmony_ci * <br> 1. Mandatory parameters are left unspecified. 20261847f8eSopenharmony_ci * <br> 2. Incorrect parameters types. 20361847f8eSopenharmony_ci * <br> 3. Parameter verification failed. 20461847f8eSopenharmony_ci * @throws { BusinessError } 1300002 - Abnormal state. Possible causes: 20561847f8eSopenharmony_ci * <br> 1. The UIExtension window proxy is abnormal. 20661847f8eSopenharmony_ci * <br> 2. Not the UIExtensionAbility process calling. 20761847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 20861847f8eSopenharmony_ci * @systemapi 20961847f8eSopenharmony_ci * @since 13 21061847f8eSopenharmony_ci */ 21161847f8eSopenharmony_ci hidePrivacyContentForHost(shouldHide: boolean): Promise<void>; 21261847f8eSopenharmony_ci } 21361847f8eSopenharmony_ci 21461847f8eSopenharmony_ci /** 21561847f8eSopenharmony_ci * Properties of UIExtension window 21661847f8eSopenharmony_ci * 21761847f8eSopenharmony_ci * @interface UIExtensionHostWindowProxyProperties 21861847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 21961847f8eSopenharmony_ci * @systemapi 22061847f8eSopenharmony_ci * @since 11 22161847f8eSopenharmony_ci */ 22261847f8eSopenharmony_ci interface UIExtensionHostWindowProxyProperties { 22361847f8eSopenharmony_ci /** 22461847f8eSopenharmony_ci * The position and size of the UIExtension window 22561847f8eSopenharmony_ci * 22661847f8eSopenharmony_ci * @type { window.Rect } 22761847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 22861847f8eSopenharmony_ci * @systemapi 22961847f8eSopenharmony_ci * @since 11 23061847f8eSopenharmony_ci */ 23161847f8eSopenharmony_ci uiExtensionHostWindowProxyRect: window.Rect; 23261847f8eSopenharmony_ci } 23361847f8eSopenharmony_ci} 23461847f8eSopenharmony_ci 23561847f8eSopenharmony_ciexport default uiExtensionHost; 236