• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022 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 "./basic";
17import { Callback } from "./basic";
18import Want from './@ohos.app.ability.Want';
19import formInfo from './@ohos.app.form.formInfo'
20
21/**
22 * interface of formHost.
23 *
24 * @name formHost
25 * @since 8
26 * @syscap SystemCapability.Ability.Form
27 * @systemapi hide for inner use.
28 * @deprecated since 9
29 * @useinstead ohos.app.form.formHost
30 */
31declare namespace formHost {
32    /**
33     * Deletes an obtained form by its ID.
34     *
35     * <p>After this method is called, the form won't be available for use by the application and the Form Manager
36     * Service no longer keeps the cache information about the form.</p>
37     *
38     * @since 8
39     * @syscap SystemCapability.Ability.Form
40     * @param formId Indicates the form ID
41     * @returns -
42     * @permission ohos.permission.REQUIRE_FORM
43     */
44    function deleteForm(formId: string, callback: AsyncCallback<void>): void;
45    function deleteForm(formId: string): Promise<void>;
46
47    /**
48     * Releases an obtained form by its ID.
49     *
50     * <p>After this method is called, the form won't be available for use by the application, but the Form Manager
51     * Service still keeps the cache information about the form, so that the application can quickly obtain it based on
52     * the {@code formId}.</p>
53     *
54     * @since 8
55     * @syscap SystemCapability.Ability.Form
56     * @param formId Indicates the form ID
57     * @param isReleaseCache Indicates whether or not release cache
58     * @returns -
59     * @permission ohos.permission.REQUIRE_FORM
60     */
61    function releaseForm(formId: string, callback: AsyncCallback<void>): void;
62    function releaseForm(formId: string, isReleaseCache: boolean, callback: AsyncCallback<void>): void;
63    function releaseForm(formId: string, isReleaseCache?: boolean): Promise<void>;
64
65    /**
66     * Requests for form update.
67     *
68     * <p>This method must be called when the application has detected that a system setting item (such as the language,
69     * resolution, or screen orientation) being listened for has changed. Upon receiving the update request, the form
70     * provider automatically updates the form data (if there is any update) through the form framework, with the update
71     * process being unperceivable by the application.</p>
72     *
73     * @since 8
74     * @syscap SystemCapability.Ability.Form
75     * @param formId Indicates the ID of the form to update.
76     * @returns -
77     * @permission ohos.permission.REQUIRE_FORM
78     */
79    function requestForm(formId: string, callback: AsyncCallback<void>): void;
80    function requestForm(formId: string): Promise<void>;
81
82    /**
83     * Converts a specified temporary form that has been obtained by the application into a normal form.
84     *
85     * @since 8
86     * @syscap SystemCapability.Ability.Form
87     * @param formId Indicates the ID of the temporary form to convert.
88     * @returns -
89     * @permission ohos.permission.REQUIRE_FORM
90     */
91    function castTempForm(formId: string, callback: AsyncCallback<void>): void;
92    function castTempForm(formId: string): Promise<void>;
93
94    /**
95     * Sends a notification to the form framework to make the specified forms visible.
96     *
97     * <p>After this method is successfully called, onVisibilityChange will be called to notify the form provider of
98     * the form visibility change event.</p>
99     *
100     * @since 8
101     * @syscap SystemCapability.Ability.Form
102     * @param formIds Indicates the IDs of the forms to be made visible.
103     * @returns -
104     * @permission ohos.permission.REQUIRE_FORM
105     */
106    function notifyVisibleForms(formIds: Array<string>, callback: AsyncCallback<void>): void;
107    function notifyVisibleForms(formIds: Array<string>): Promise<void>;
108
109    /**
110     * Sends a notification to the form framework to make the specified forms invisible.
111     *
112     * <p>After this method is successfully called, onVisibilityChange will be called to notify the form provider of
113     * the form visibility change event.</p>
114     *
115     * @since 8
116     * @syscap SystemCapability.Ability.Form
117     * @param formIds Indicates the IDs of the forms to be made invisible.
118     * @returns -
119     * @permission ohos.permission.REQUIRE_FORM
120     */
121    function notifyInvisibleForms(formIds: Array<string>, callback: AsyncCallback<void>): void;
122    function notifyInvisibleForms(formIds: Array<string>): Promise<void>;
123
124    /**
125     * Notify the form framework to make the specified forms updatable.
126     *
127     * <p>You can use this method to set form refresh state to true, the form can receive new
128     * update from service.</p>
129     *
130     * @since 8
131     * @syscap SystemCapability.Ability.Form
132     * @param formIds Indicates the IDs of the forms to be made invisible.
133     * @returns -
134     * @permission ohos.permission.REQUIRE_FORM
135     */
136    function enableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void>): void;
137    function enableFormsUpdate(formIds: Array<string>): Promise<void>;
138
139    /**
140     * Notify the form framework to make the specified forms non updatable.
141     *
142     * <p>You can use this method to set form refresh state to false, the form do not receive
143     * new update from service.</p>
144     *
145     * @since 8
146     * @syscap SystemCapability.Ability.Form
147     * @param formIds Indicates the IDs of the forms to be made invisible.
148     * @returns -
149     * @permission ohos.permission.REQUIRE_FORM
150     */
151    function disableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void>): void;
152    function disableFormsUpdate(formIds: Array<string>): Promise<void>;
153
154    /**
155     * Checks whether the system is ready.
156     *
157     * <p>You can use this method to obtain the system is ready.</p>
158     *
159     * @since 8
160     * @syscap SystemCapability.Ability.Form
161     * @returns -
162     */
163    function isSystemReady(callback: AsyncCallback<void>): void;
164    function isSystemReady(): Promise<void>;
165
166    /**
167     * Obtains the FormInfo objects provided by all applications on the device.
168     *
169     * @since 8
170     * @syscap SystemCapability.Ability.Form
171     * @returns Returns the {@link FormInfo}
172     * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
173     */
174    function getAllFormsInfo(callback: AsyncCallback<Array<formInfo.FormInfo>>): void;
175    function getAllFormsInfo(): Promise<Array<formInfo.FormInfo>>;
176
177    /**
178     * Obtains the FormInfo objects provided by a specified application on the device.
179     *
180     * @since 8
181     * @syscap SystemCapability.Ability.Form
182     * @param bundleName Indicates the bundle name of the application.
183     * @param moduleName Indicates the module name of the application.
184     * @returns Returns the {@link FormInfo}
185     * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
186     */
187    function getFormsInfo(bundleName: string, callback: AsyncCallback<Array<formInfo.FormInfo>>): void;
188    function getFormsInfo(bundleName: string, moduleName: string, callback: AsyncCallback<Array<formInfo.FormInfo>>): void;
189    function getFormsInfo(bundleName: string, moduleName?: string): Promise<Array<formInfo.FormInfo>>;
190
191    /**
192     * Deletes invalid forms of the application in the Form Manager Service based on the list of.
193     *
194     * <p>You can use this method to delete invalid forms of the application.</p>
195     *
196     * @since 8
197     * @syscap SystemCapability.Ability.Form
198     * @param formIds Indicates the specify form id.
199     * @returns Returns the number of invalid forms deleted by the Form Manager Service
200     * @permission ohos.permission.REQUIRE_FORM
201     */
202    function deleteInvalidForms(formIds: Array<string>, callback: AsyncCallback<number>): void;
203    function deleteInvalidForms(formIds: Array<string>): Promise<number>;
204
205    /**
206     * Obtains the Form state.
207     *
208     * <p>You can use this method to obtains the form state.</p>
209     *
210     * @since 8
211     * @syscap SystemCapability.Ability.Form
212     * @param want Indicates want of the form.
213     * @returns Returns form state {@link FormStateInfo}
214     * @permission ohos.permission.REQUIRE_FORM and ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
215     */
216    function acquireFormState(want: Want, callback: AsyncCallback<formInfo.FormStateInfo>): void;
217    function acquireFormState(want: Want): Promise<formInfo.FormStateInfo>;
218
219    /**
220     * Listens to the event of uninstall form.
221     *
222     * <p>You can use this method to listen to the event of uninstall form.</p>
223     *
224     * @since 8
225     * @syscap SystemCapability.Ability.Form
226     * @param type Indicates event type.
227     * @returns -
228     */
229    function on(type: "formUninstall", callback: Callback<string>): void;
230
231    /**
232     * Cancels listening to the event of uninstall form.
233     *
234     * <p>You can use this method to cancel listening to the event of uninstall form.</p>
235     *
236     * @since 8
237     * @syscap SystemCapability.Ability.Form
238     * @param type Indicates event type.
239     * @returns -
240     */
241    function off(type: "formUninstall", callback?: Callback<string>): void;
242
243    /**
244     * notify form is Visible
245     *
246     * <p>You can use this method to notify form visible state.</p>
247     *
248     * @since 8
249     * @syscap SystemCapability.Ability.Form
250     * @param formIds Indicates the specify form id.
251     * @param isVisible Indicates whether visible.
252     * @returns -
253     * @permission ohos.permission.REQUIRE_FORM
254     */
255    function notifyFormsVisible(formIds: Array<string>, isVisible: boolean, callback: AsyncCallback<void>): void;
256    function notifyFormsVisible(formIds: Array<string>, isVisible: boolean): Promise<void>;
257
258    /**
259     * notify form enable update state.
260     *
261     * <p>You can use this method to notify form enable update state.</p>
262     *
263     * @since 8
264     * @syscap SystemCapability.Ability.Form
265     * @param formIds Indicates the specify form id.
266     * @param isEnableUpdate Indicates whether enable update.
267     * @returns -
268     * @permission ohos.permission.REQUIRE_FORM
269     */
270    function notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean, callback: AsyncCallback<void>): void;
271    function notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean): Promise<void>;
272}
273export default formHost;