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