• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023 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
16import { AsyncCallback } from './@ohos.base';
17import { Callback } from './@ohos.base';
18import formInfo from './@ohos.app.form.formInfo';
19
20/**
21 * Interface of formObserver.
22 *
23 * @namespace formObserver
24 * @syscap SystemCapability.Ability.Form
25 * @systemapi
26 * @since 10
27 */
28declare namespace formObserver {
29  /**
30   * Listens to the event of add form.
31   * <p>You can use this method to listen to the event of add form.</p>
32   *
33   * @permission ohos.permission.OBSERVE_FORM_RUNNING
34   * @param { 'formAdd' } type - Indicates event type.
35   * @param { Callback<formInfo.RunningFormInfo> } observerCallback - The callback is used to return the running
36   *                                                                  form info.
37   * @throws { BusinessError } 202 - The application is not a system application.
38   * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
39   * @syscap SystemCapability.Ability.Form
40   * @systemapi
41   * @since 10
42   */
43  function on(type: 'formAdd', observerCallback: Callback<formInfo.RunningFormInfo>): void;
44
45  /**
46   * Listens to the event of add form.
47   * <p>You can use this method to listen to the event of add form for a particular card host.</p>
48   *
49   * @permission ohos.permission.OBSERVE_FORM_RUNNING
50   * @param { 'formAdd' } type - Indicates event type.
51   * @param { string } hostBundleName - Indicates the bundle name of the form host application.
52   * @param { Callback<formInfo.RunningFormInfo> } observerCallback - The callback is used to return the running
53   *                                                                  form info.
54   * @throws { BusinessError } 202 - The application is not a system application.
55   * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
56   * @syscap SystemCapability.Ability.Form
57   * @systemapi
58   * @since 10
59   */
60  function on(type: 'formAdd', hostBundleName: string, observerCallback: Callback<formInfo.RunningFormInfo>): void;
61
62  /**
63   * Cancels listening to the event of add form.
64   * <p>You can use this method to cancel listening to the event of add form.</p>
65   *
66   * @permission ohos.permission.OBSERVE_FORM_RUNNING
67   * @param { 'formAdd' } type - Indicates event type.
68   * @param { string } [hostBundleName] - Indicates the bundle name of the form host application.
69   * @param { Callback<formInfo.RunningFormInfo> } [observerCallback] - The callback is used to return the running
70   *                                                                    form info.
71   * @throws { BusinessError } 202 - The application is not a system application.
72   * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
73   * @syscap SystemCapability.Ability.Form
74   * @systemapi
75   * @since 10
76   */
77  function off(type: 'formAdd', hostBundleName?: string, observerCallback?: Callback<formInfo.RunningFormInfo>): void;
78
79  /**
80   * Listens to the event of remove form.
81   * <p>You can use this method to listen to the event of remove form.</p>
82   *
83   * @permission ohos.permission.OBSERVE_FORM_RUNNING
84   * @param { 'formRemove' } type - Indicates event type.
85   * @param { Callback<formInfo.RunningFormInfo> } observerCallback - The callback is used to return the running
86   *                                                                  form info.
87   * @throws { BusinessError } 202 - The application is not a system application.
88   * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
89   * @syscap SystemCapability.Ability.Form
90   * @systemapi
91   * @since 10
92   */
93  function on(type: 'formRemove', observerCallback: Callback<formInfo.RunningFormInfo>): void;
94
95  /**
96   * Listens to the event of remove form.
97   * <p>You can use this method to listen to the event of remove form for a particular card host.</p>
98   *
99   * @permission ohos.permission.OBSERVE_FORM_RUNNING
100   * @param { 'formRemove' } type - Indicates event type.
101   * @param { string } hostBundleName - Indicates the bundle name of the form host application.
102   * @param { Callback<formInfo.RunningFormInfo> } observerCallback - The callback is used to return the running
103   *                                                                  form info.
104   * @throws { BusinessError } 202 - The application is not a system application.
105   * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
106   * @syscap SystemCapability.Ability.Form
107   * @systemapi
108   * @since 10
109   */
110  function on(type: 'formRemove', hostBundleName: string, observerCallback: Callback<formInfo.RunningFormInfo>): void;
111
112  /**
113   * Cancels listening to the event of remove form.
114   * <p>You can use this method to cancel listening to the event of remove form.</p>
115   *
116   * @permission ohos.permission.OBSERVE_FORM_RUNNING
117   * @param { 'formRemove' } type - Indicates event type.
118   * @param { string } [hostBundleName] - Indicates the bundle name of the form host application.
119   * @param { Callback<formInfo.RunningFormInfo> } [observerCallback] - The callback is used to return the running
120   *                                                                    form info.
121   * @throws { BusinessError } 202 - The application is not a system application.
122   * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
123   * @syscap SystemCapability.Ability.Form
124   * @systemapi
125   * @since 10
126   */
127  function off(type: 'formRemove', hostBundleName?: string, observerCallback?: Callback<formInfo.RunningFormInfo>): void;
128
129  /**
130   * Listens to the event of notifyVisible type change.
131   * <p>You can use this method to listen to the event of notifyVisible type change.</p>
132   *
133   * @permission ohos.permission.OBSERVE_FORM_RUNNING
134   * @param { 'notifyVisible' } type - Indicates event type.
135   * @param { Callback<Array<formInfo.RunningFormInfo>> } observerCallback - The callback is used to return
136   *                                                                         the running form info.
137   * @throws { BusinessError } 202 - The application is not a system application.
138   * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
139   * @syscap SystemCapability.Ability.Form
140   * @systemapi
141   * @since 10
142   */
143  function on(type: 'notifyVisible', observerCallback: Callback<Array<formInfo.RunningFormInfo>>): void;
144
145  /**
146   * Listens to the event of notifyVisible type change.
147   * <p>You can use this method to listen to the event of notifyVisible type change for a particular card host.</p>
148   *
149   * @permission ohos.permission.OBSERVE_FORM_RUNNING
150   * @param { 'notifyVisible' } type - Indicates event type.
151   * @param { string } hostBundleName - Indicates the bundle name of the form host application.
152   * @param { Callback<Array<formInfo.RunningFormInfo>> } observerCallback - The callback is used to return
153   *                                                                         the running form info.
154   * @throws { BusinessError } 202 - The application is not a system application.
155   * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
156   * @syscap SystemCapability.Ability.Form
157   * @systemapi
158   * @since 10
159   */
160  function on(
161    type: 'notifyVisible',
162    hostBundleName: string,
163    observerCallback: Callback<Array<formInfo.RunningFormInfo>>
164  ): void;
165
166  /**
167   * Listens to the event of notifyInvisible type change.
168   * <p>You can use this method to listen to the event of notifyInvisible type change.</p>
169   *
170   * @permission ohos.permission.OBSERVE_FORM_RUNNING
171   * @param { 'notifyInvisible' } type - Indicates event type.
172   * @param { Callback<Array<formInfo.RunningFormInfo>> } observerCallback - The callback is used to return
173   *                                                                         the running form info.
174   * @throws { BusinessError } 202 - The application is not a system application.
175   * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
176   * @syscap SystemCapability.Ability.Form
177   * @systemapi
178   * @since 10
179   */
180  function on(type: 'notifyInvisible', observerCallback: Callback<Array<formInfo.RunningFormInfo>>): void;
181
182  /**
183   * Listens to the event of notifyInvisible type change.
184   * <p>You can use this method to listen to the event of notifyInvisible type change for a particular card host.</p>
185   *
186   * @permission ohos.permission.OBSERVE_FORM_RUNNING
187   * @param { 'notifyInvisible' } type - Indicates event type.
188   * @param { string } hostBundleName - Indicates the bundle name of the form host application.
189   * @param { Callback<Array<formInfo.RunningFormInfo>> } observerCallback - The callback is used to return
190   *                                                                         the running form info.
191   * @throws { BusinessError } 202 - The application is not a system application.
192   * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
193   * @syscap SystemCapability.Ability.Form
194   * @systemapi
195   * @since 10
196   */
197  function on(
198    type: 'notifyInvisible',
199    hostBundleName: string,
200    observerCallback: Callback<Array<formInfo.RunningFormInfo>>,
201  ): void;
202
203  /**
204   * Cancels listening to the event of notifyVisible type change.
205   * <p>You can use this method to cancel listening to the event of notifyVisible type change.</p>
206   *
207   * @permission ohos.permission.OBSERVE_FORM_RUNNING
208   * @param { 'notifyVisible' } type - Indicates event type.
209   * @param { string } [hostBundleName] - Indicates the bundle name of the form host application.
210   * @param { Callback<Array<formInfo.RunningFormInfo>> } [observerCallback] - The callback is used to return
211   *                                                                  the running form info.
212   * @throws { BusinessError } 202 - The application is not a system application.
213   * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
214   * @syscap SystemCapability.Ability.Form
215   * @systemapi
216   * @since 10
217   */
218  function off(
219    type: 'notifyVisible',
220    hostBundleName?: string,
221    observerCallback?: Callback<Array<formInfo.RunningFormInfo>>
222  ): void;
223
224  /**
225   * Cancels listening to the event of notifyInvisible type change.
226   * <p>You can use this method to cancel listening to the event of notifyInvisible type change.</p>
227   *
228   * @permission ohos.permission.OBSERVE_FORM_RUNNING
229   * @param { 'notifyInvisible' } type - Indicates event type.
230   * @param { string } hostBundleName - Indicates the bundle name of the form host application.
231   * @param { Callback<Array<formInfo.RunningFormInfo>> } [observerCallback] - The callback is used to return
232   *                                                                         the running form info.
233   * @throws { BusinessError } 202 - The application is not a system application.
234   * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
235   * @syscap SystemCapability.Ability.Form
236   * @systemapi
237   * @since 10
238   */
239  function off(
240    type: 'notifyInvisible',
241    hostBundleName?: string,
242    observerCallback?: Callback<Array<formInfo.RunningFormInfo>>
243  ): void;
244
245  /**
246   * Obtains the RunningFormInfo objects provided by a specific card host application on the device.
247   *
248   * @permission ohos.permission.OBSERVE_FORM_RUNNING
249   * @param { AsyncCallback<Array<formInfo.RunningFormInfo>> } callback - The callback is used to return the
250   *                                                                      RunningFormInfo.
251   * @param { string } [hostBundleName] - Indicates the bundle name of the form host application.
252   * @throws { BusinessError } 201 - Permissions denied.
253   * @throws { BusinessError } 202 - The application is not a system application.
254   * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
255   * @throws { BusinessError } 16500050 - An IPC connection error happened.
256   * @throws { BusinessError } 16500060 - A service connection error happened, please try again later.
257   * @syscap SystemCapability.Ability.Form
258   * @systemapi
259   * @since 10
260   */
261  function getRunningFormInfos(callback: AsyncCallback<Array<formInfo.RunningFormInfo>>, hostBundleName?: string): void;
262
263  /**
264   * Obtains the RunningFormInfo objects provided by a specific card host application on the device.
265   *
266   * @permission ohos.permission.OBSERVE_FORM_RUNNING
267   * @param { string } [hostBundleName] - Indicates the bundle name of the form host application.
268   * @returns { Promise<Array<formInfo.RunningFormInfo>> } Returns the RunningFormInfo.
269   * @throws { BusinessError } 201 - Permissions denied.
270   * @throws { BusinessError } 202 - The application is not a system application.
271   * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
272   * @throws { BusinessError } 16500050 - An IPC connection error happened.
273   * @throws { BusinessError } 16500060 - A service connection error happened, please try again later.
274   * @syscap SystemCapability.Ability.Form
275   * @systemapi
276   * @since 10
277   */
278  function getRunningFormInfos(hostBundleName?: string): Promise<Array<formInfo.RunningFormInfo>>;
279
280  /**
281   * Obtains the RunningFormInfo objects by FormProviderFilter.
282   *
283   * @permission ohos.permission.OBSERVE_FORM_RUNNING
284   * @param { formInfo.FormProviderFilter } formProviderFilter - Indicates the form provider app info.
285   * @returns { Promise<Array<formInfo.RunningFormInfo>> } The promise returned by the function.
286   * @throws { BusinessError } 201 - Permissions denied.
287   * @throws { BusinessError } 202 - The application is not a system application.
288   * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
289   * @throws { BusinessError } 16500050 - An IPC connection error happened.
290   * @throws { BusinessError } 16500100 - Failed to obtain the configuration information.
291   * @throws { BusinessError } 16501000 - An internal functional error occurred.
292   * @syscap SystemCapability.Ability.Form
293   * @systemapi
294   * @stagemodelonly
295   * @since 10
296   */
297  function getRunningFormInfosByFilter(
298    formProviderFilter: formInfo.FormProviderFilter
299  ): Promise<Array<formInfo.RunningFormInfo>>;
300
301  /**
302   * Obtains the RunningFormInfo objects by FormProviderFilter.
303   *
304   * @permission ohos.permission.OBSERVE_FORM_RUNNING
305   * @param { formInfo.FormProviderFilter } formProviderFilter - Indicates the form provider app info.
306   * @param { AsyncCallback<Array<formInfo.RunningFormInfo>> } callback - The callback of getFormInstancesByFilter.
307   * @throws { BusinessError } 201 - Permissions denied.
308   * @throws { BusinessError } 202 - The application is not a system application.
309   * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
310   * @throws { BusinessError } 16500050 - An IPC connection error happened.
311   * @throws { BusinessError } 16500100 - Failed to obtain the configuration information.
312   * @throws { BusinessError } 16501000 - An internal functional error occurred.
313   * @syscap SystemCapability.Ability.Form
314   * @systemapi
315   * @stagemodelonly
316   * @since 10
317   */
318  function getRunningFormInfosByFilter(
319    formProviderFilter: formInfo.FormProviderFilter,
320    callback: AsyncCallback<Array<formInfo.RunningFormInfo>>
321  ): void;
322
323  /**
324   * Obtains the RunningFormInfo object by formId.
325   *
326   * @permission ohos.permission.OBSERVE_FORM_RUNNING
327   * @param { string } formId - Indicates the form provider formId.
328   * @returns { Promise<formInfo.RunningFormInfo> } The promise returned by the function.
329   * @throws { BusinessError } 201 - Permissions denied.
330   * @throws { BusinessError } 202 - The application is not a system application.
331   * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
332   * @throws { BusinessError } 16500050 - An IPC connection error happened.
333   * @throws { BusinessError } 16500100 - Failed to obtain the configuration information.
334   * @throws { BusinessError } 16501000 - An internal functional error occurred.
335   * @syscap SystemCapability.Ability.Form
336   * @systemapi
337   * @stagemodelonly
338   * @since 10
339   */
340  function getRunningFormInfoById(formId: string): Promise<formInfo.RunningFormInfo>;
341
342  /**
343   * Obtains the RunningFormInfo object by formId.
344   *
345   * @permission ohos.permission.OBSERVE_FORM_RUNNING
346   * @param { string } formId - Indicates the form provider formId.
347   * @param { AsyncCallback<formInfo.RunningFormInfo> } callback - The callback of getFormInstancesById.
348   * @throws { BusinessError } 201 - Permissions denied.
349   * @throws { BusinessError } 202 - The application is not a system application.
350   * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
351   * @throws { BusinessError } 16500050 - An IPC connection error happened.
352   * @throws { BusinessError } 16500100 - Failed to obtain the configuration information.
353   * @throws { BusinessError } 16501000 - An internal functional error occurred.
354   * @syscap SystemCapability.Ability.Form
355   * @systemapi
356   * @stagemodelonly
357   * @since 10
358   */
359  function getRunningFormInfoById(formId: string, callback: AsyncCallback<formInfo.RunningFormInfo>): void;
360}
361export default formObserver;
362