161847f8eSopenharmony_ci/* 261847f8eSopenharmony_ci * Copyright (c) 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_ci 2361847f8eSopenharmony_ciimport { Callback } from './@ohos.base'; 2461847f8eSopenharmony_ciimport window from './@ohos.window'; 2561847f8eSopenharmony_ci/** 2661847f8eSopenharmony_ci * uiExtension. 2761847f8eSopenharmony_ci * 2861847f8eSopenharmony_ci * @namespace uiExtension 2961847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 3061847f8eSopenharmony_ci * @atomicservice 3161847f8eSopenharmony_ci * @since 12 3261847f8eSopenharmony_ci */ 3361847f8eSopenharmony_cideclare namespace uiExtension { 3461847f8eSopenharmony_ci /** 3561847f8eSopenharmony_ci * The proxy of the UIExtension window. 3661847f8eSopenharmony_ci * 3761847f8eSopenharmony_ci * @interface WindowProxy 3861847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 3961847f8eSopenharmony_ci * @atomicservice 4061847f8eSopenharmony_ci * @since 12 4161847f8eSopenharmony_ci */ 4261847f8eSopenharmony_ci interface WindowProxy { 4361847f8eSopenharmony_ci /** 4461847f8eSopenharmony_ci * Get the avoid area. 4561847f8eSopenharmony_ci * 4661847f8eSopenharmony_ci * @param { window.AvoidAreaType } type - Type of the avoid area. 4761847f8eSopenharmony_ci * @returns { window.AvoidArea } Area where the window cannot be displayed. 4861847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 4961847f8eSopenharmony_ci * <br> 1. Mandatory parameters are left unspecified. 5061847f8eSopenharmony_ci * <br> 2. Incorrect parameters types. 5161847f8eSopenharmony_ci * <br> 3. Parameter verification failed. 5261847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 5361847f8eSopenharmony_ci * @atomicservice 5461847f8eSopenharmony_ci * @since 12 5561847f8eSopenharmony_ci */ 5661847f8eSopenharmony_ci getWindowAvoidArea(type: window.AvoidAreaType): window.AvoidArea; 5761847f8eSopenharmony_ci 5861847f8eSopenharmony_ci /** 5961847f8eSopenharmony_ci * Register the callback of avoidAreaChange. 6061847f8eSopenharmony_ci * 6161847f8eSopenharmony_ci * @param { 'avoidAreaChange' } type - The value is fixed at 'avoidAreaChange', indicating the event of changes to the avoid area. 6261847f8eSopenharmony_ci * @param { Callback<AvoidAreaInfo> } callback - Callback used to return the avoid area information. 6361847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 6461847f8eSopenharmony_ci * <br> 1. Mandatory parameters are left unspecified. 6561847f8eSopenharmony_ci * <br> 2. Incorrect parameters types. 6661847f8eSopenharmony_ci * <br> 3. Parameter verification failed. 6761847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 6861847f8eSopenharmony_ci * @atomicservice 6961847f8eSopenharmony_ci * @since 12 7061847f8eSopenharmony_ci */ 7161847f8eSopenharmony_ci on(type: 'avoidAreaChange', callback: Callback<AvoidAreaInfo>): void; 7261847f8eSopenharmony_ci 7361847f8eSopenharmony_ci /** 7461847f8eSopenharmony_ci * Unregister the callback of avoidAreaChange. 7561847f8eSopenharmony_ci * 7661847f8eSopenharmony_ci * @param { 'avoidAreaChange' } type - The value is fixed at 'avoidAreaChange', indicating the event of changes to the avoid area. 7761847f8eSopenharmony_ci * @param { Callback<AvoidAreaInfo> } callback - Callback used to return the avoid area information. 7861847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 7961847f8eSopenharmony_ci * <br> 1. Mandatory parameters are left unspecified. 8061847f8eSopenharmony_ci * <br> 2. Incorrect parameters types. 8161847f8eSopenharmony_ci * <br> 3. Parameter verification failed. 8261847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 8361847f8eSopenharmony_ci * @atomicservice 8461847f8eSopenharmony_ci * @since 12 8561847f8eSopenharmony_ci */ 8661847f8eSopenharmony_ci off(type: 'avoidAreaChange', callback?: Callback<AvoidAreaInfo>): void; 8761847f8eSopenharmony_ci 8861847f8eSopenharmony_ci /** 8961847f8eSopenharmony_ci * Register the callback of windowSizeChange. 9061847f8eSopenharmony_ci * 9161847f8eSopenharmony_ci * @param { 'windowSizeChange' } type - The value is fixed at 'windowSizeChange', indicating the window size change event. 9261847f8eSopenharmony_ci * @param { Callback<window.Size> } callback - Callback used to return the window size. 9361847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 9461847f8eSopenharmony_ci * <br> 1. Mandatory parameters are left unspecified. 9561847f8eSopenharmony_ci * <br> 2. Incorrect parameters types. 9661847f8eSopenharmony_ci * <br> 3. Parameter verification failed. 9761847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 9861847f8eSopenharmony_ci * @atomicservice 9961847f8eSopenharmony_ci * @since 12 10061847f8eSopenharmony_ci */ 10161847f8eSopenharmony_ci on(type: 'windowSizeChange', callback: Callback<window.Size>): void; 10261847f8eSopenharmony_ci 10361847f8eSopenharmony_ci /** 10461847f8eSopenharmony_ci * Unregister the callback of windowSizeChange. 10561847f8eSopenharmony_ci * 10661847f8eSopenharmony_ci * @param { 'windowSizeChange' } type - The value is fixed at 'windowSizeChange', indicating the window size change event. 10761847f8eSopenharmony_ci * @param { Callback<window.Size> } callback - Callback used to return the window size. 10861847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 10961847f8eSopenharmony_ci * <br> 1. Mandatory parameters are left unspecified. 11061847f8eSopenharmony_ci * <br> 2. Incorrect parameters types. 11161847f8eSopenharmony_ci * <br> 3. Parameter verification failed. 11261847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 11361847f8eSopenharmony_ci * @atomicservice 11461847f8eSopenharmony_ci * @since 12 11561847f8eSopenharmony_ci */ 11661847f8eSopenharmony_ci off(type: 'windowSizeChange', callback?: Callback<window.Size>): void; 11761847f8eSopenharmony_ci 11861847f8eSopenharmony_ci /** 11961847f8eSopenharmony_ci * Hide the non-secure windows. 12061847f8eSopenharmony_ci * When called by modal UIExtension and shouldHide == false, the "ohos.permission.ALLOW_SHOW_NON_SECURE_WINDOWS" permission is required. 12161847f8eSopenharmony_ci * 12261847f8eSopenharmony_ci * @permission ohos.permission.ALLOW_SHOW_NON_SECURE_WINDOWS 12361847f8eSopenharmony_ci * @param { boolean } shouldHide - Hide the non-secure windows if true, otherwise means the opposite. 12461847f8eSopenharmony_ci * @returns { Promise<void> } - The promise returned by the function. 12561847f8eSopenharmony_ci * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 12661847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 12761847f8eSopenharmony_ci * <br> 1. Mandatory parameters are left unspecified. 12861847f8eSopenharmony_ci * <br> 2. Incorrect parameters types. 12961847f8eSopenharmony_ci * <br> 3. Parameter verification failed. 13061847f8eSopenharmony_ci * @throws { BusinessError } 1300002 - Abnormal state. Possible causes: 13161847f8eSopenharmony_ci * <br> 1. Permission denied. Interface caller does not have permission "ohos.permission.ALLOW_SHOW_NON_SECURE_WINDOWS". 13261847f8eSopenharmony_ci * <br> 2. The UIExtension window proxy is abnormal. 13361847f8eSopenharmony_ci * @throws { BusinessError } 1300003 - This window manager service works abnormally. 13461847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 13561847f8eSopenharmony_ci * @systemapi 13661847f8eSopenharmony_ci * @since 12 13761847f8eSopenharmony_ci */ 13861847f8eSopenharmony_ci hideNonSecureWindows(shouldHide: boolean): Promise<void>; 13961847f8eSopenharmony_ci 14061847f8eSopenharmony_ci /** 14161847f8eSopenharmony_ci * Create sub window. 14261847f8eSopenharmony_ci * 14361847f8eSopenharmony_ci * @param { string } name - window name of sub window. 14461847f8eSopenharmony_ci * @param { window.SubWindowOptions } subWindowOptions - options of sub window creation. 14561847f8eSopenharmony_ci * @returns { Promise<window.Window> } Promise used to return the subwindow. 14661847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 14761847f8eSopenharmony_ci * <br> 1. Mandatory parameters are left unspecified. 14861847f8eSopenharmony_ci * <br> 2. Incorrect parameters types. 14961847f8eSopenharmony_ci * <br> 3. Parameter verification failed. 15061847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. Failed to call the API due to limited device capabilities. 15161847f8eSopenharmony_ci * @throws { BusinessError } 1300002 - This window state is abnormal. 15261847f8eSopenharmony_ci * @throws { BusinessError } 1300005 - This window proxy is abnormal. 15361847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 15461847f8eSopenharmony_ci * @StageModelOnly 15561847f8eSopenharmony_ci * @atomicservice 15661847f8eSopenharmony_ci * @since 12 15761847f8eSopenharmony_ci */ 15861847f8eSopenharmony_ci createSubWindowWithOptions(name: string, subWindowOptions: window.SubWindowOptions): Promise<window.Window>; 15961847f8eSopenharmony_ci 16061847f8eSopenharmony_ci /** 16161847f8eSopenharmony_ci * Set the watermark flag on the UIExtension window 16261847f8eSopenharmony_ci * 16361847f8eSopenharmony_ci * @param { boolean } enable - Add water mark flag to the UIExtension window if true, or remove flag if false 16461847f8eSopenharmony_ci * @returns { Promise<void> } - The promise returned by the function 16561847f8eSopenharmony_ci * @throws { BusinessError } 1300002 - The UIExtension window proxy is abnormal. 16661847f8eSopenharmony_ci * @throws { BusinessError } 1300003 - This window manager service works abnormally. 16761847f8eSopenharmony_ci * @throws { BusinessError } 1300008 - The display device is abnormal. 16861847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 16961847f8eSopenharmony_ci * @systemapi 17061847f8eSopenharmony_ci * @since 12 17161847f8eSopenharmony_ci */ 17261847f8eSopenharmony_ci setWaterMarkFlag(enable: boolean): Promise<void>; 17361847f8eSopenharmony_ci } 17461847f8eSopenharmony_ci 17561847f8eSopenharmony_ci /** 17661847f8eSopenharmony_ci * Defines the avoid area information. 17761847f8eSopenharmony_ci * 17861847f8eSopenharmony_ci * @interface AvoidAreaInfo 17961847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 18061847f8eSopenharmony_ci * @atomicservice 18161847f8eSopenharmony_ci * @since 12 18261847f8eSopenharmony_ci */ 18361847f8eSopenharmony_ci interface AvoidAreaInfo { 18461847f8eSopenharmony_ci /** 18561847f8eSopenharmony_ci * Describes the type of avoid area. 18661847f8eSopenharmony_ci * 18761847f8eSopenharmony_ci * @type { window.AvoidAreaType } 18861847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 18961847f8eSopenharmony_ci * @atomicservice 19061847f8eSopenharmony_ci * @since 12 19161847f8eSopenharmony_ci */ 19261847f8eSopenharmony_ci type: window.AvoidAreaType; 19361847f8eSopenharmony_ci 19461847f8eSopenharmony_ci /** 19561847f8eSopenharmony_ci * Describes the position and size of avoid area. 19661847f8eSopenharmony_ci * 19761847f8eSopenharmony_ci * @type { window.AvoidArea } 19861847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 19961847f8eSopenharmony_ci * @atomicservice 20061847f8eSopenharmony_ci * @since 12 20161847f8eSopenharmony_ci */ 20261847f8eSopenharmony_ci area: window.AvoidArea; 20361847f8eSopenharmony_ci } 20461847f8eSopenharmony_ci} 20561847f8eSopenharmony_ci 20661847f8eSopenharmony_ciexport default uiExtension; 207