/* * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { AsyncCallback } from './.basic'; import { Want } from './ability/want'; import { FormInfo } from './ability/forminfo'; /** * Provides utilities for system application components to access ability form * on the OHOS OS. * @name formManager * @since 7 * @sysCap AAFwk * @devices phone, tablet * @permission N/A */ declare namespace formManager { /** * user need to force refresh form. * *

You can use this method to ask for newly form from service.

* * @param formId the specify form id. * @since 7 */ function requestForm(formId: number, callback: AsyncCallback): void; function requestForm(formId: number): Promise; /** * delete forms. * *

You can use this method to delete ability form.

* * @param formId Indicates the form to be deleted. * @since 7 */ function deleteForm(formId: number, callback: AsyncCallback): void; function deleteForm(formId: number): Promise; /** * release form. * *

You can use this method to release ability form, it does not delete form cache in * form manager.

* * @param formId Indicates the form to be released. * @param isReleaseCache Indicates whether to delete cache in service. * @since 7 */ function releaseForm(formId: number, isReleaseCache: boolean, callback: AsyncCallback): void; function releaseForm(formId: number, isReleaseCache: boolean): Promise; /** * Sends a notification to the form framework to make the specified forms visible. * * @param formIds Indicates the IDs of the forms to be made visible. * @since 7 */ function notifyVisibleForms(formIds: Array, callback: AsyncCallback): void; function notifyVisibleForms(formIds: Array): Promise; /** * Sends a notification to the form framework to make the specified forms invisible. * * @param formIds Indicates the IDs of the forms to be made invisible. * @since 7 */ function notifyInvisibleForms(formIds: Array, callback: AsyncCallback): void; function notifyInvisibleForms(formIds: Array): Promise; /** * set form refresh state to true. * *

You can use this method to set form refresh state to true, the form can receive new * update from service.

* * @param formIds the specify form id. * @since 7 */ function enableFormsUpdate(formIds: Array, callback: AsyncCallback): void; function enableFormsUpdate(formIds: Array): Promise; /** * set form refresh state to false. * *

You can use this method to set form refresh state to false, the form do not receive * new update from service.

* * @param formIds the specify form id. * @since 7 */ function disableFormsUpdate(formIds: Array, callback: AsyncCallback): void; function disableFormsUpdate(formIds: Array): Promise; /** * Check form manager service ready. * *

You can use this method to check if form manager service is ready.

* * @return Returns {@code true} form manager service ready; returns {@code false} otherwise. * @since 7 */ function checkFMSReady(callback: AsyncCallback): void; function checkFMSReady(): Promise; /** * Cast temp form to narmal form. * *

You can use this method to cast a temp form to normal form.

* * @param formId the specify form id to be casted. * @since 7 */ function castTempForm(formId: number, callback: AsyncCallback): void; function castTempForm(formId: number): Promise; /** * Checks for and deletes invalid forms of the application in the Form Manager Service based on the list of valid * form IDs passed. * *

If an empty list is passed to this method, the Form Manager Service will delete all forms of the * application.

* * @param persistedIds Indicates the list of valid forms with persisted IDs. * @since 7 */ function checkAndDeleteInvalidForms(persistedIds: Array, callback: AsyncCallback): void; function checkAndDeleteInvalidForms(persistedIds: Array): Promise; /** * Updates the content of a specified JS form. * *

This method is called by a form provider to update JS form data as needed. * * @param formId Indicates the ID of the JS form to update. * @param formBindingData Indicates the object used to update the JS form displayed * on the client. * @return Returns {@code true} if the update is successful; returns {@code false} otherwise. * @throws FormException Throws this exception if the form fails to be obtained due to any of the following reasons: *

    *
  • The passed {@code formID} or {@code component} is invalid. The value of {@code formID} must be larger than 0, * and {@code component} must not be null.
  • *
  • An error occurred when connecting to the Form Manager Service.
  • *
  • The specified form ID does not exist.
  • *
  • The form has been obtained by another application and cannot be updated by the current application.
  • *
  • The form is being restored.
  • *
* @since 7 */ function updateForm(formid: number, data: FormBindingData, callback: AsyncCallback): void; function updateForm(formid: number, data: FormBindingData): Promise; /** * Set next refresh time since now. * *

This method is called by a form provider to set refresh time. * * @param formId Indicates the ID of the form to set refreshTime. * @param bundleName Indicates the bundleName of current form. * @param nextTime Indicates the next time gap now in seconds, can not be litter than 5 mins. * @return Returns {@code true} if seting succeed; returns {@code false} otherwise. * @throws FormException Throws this exception if the form fails to be obtained due to any of the following reasons: *

    *
  • The passed {@code formId} or {@code nextTime} is invalid. The value of {@code formId} must be larger * than 0, and {@code nextTime} must at least be 120 (5min).
  • *
  • An error occurred when connecting to the Form Manager Service.
  • *
  • The specified form ID does not exist.
  • *
  • The form has been obtained by another application and cannot be updated by the current application.
  • *
  • The form is being restored.
  • *
* @since 7 */ function setFormNextRefreshTime(formid: number, nextTime: number, callback: AsyncCallback): boolean; function setFormNextRefreshTime(formid: number, nextTime: number): Promise; /** * get all forms info. * *

You can use this method to get all forms info.

* * @return Returns the forms' information of all forms provided * @since 7 */ function getAllFormsInfo(callback: AsyncCallback>): void; function getAllFormsInfo(): Promise>; /** * get forms info by application name. * *

You can use this method to get all forms info of the specify application name.

* * @param bundleName application name. * @return Returns the forms' information of the specify application name. * @since 7 */ function getFormsInfoByApp(bundleName: string, callback: AsyncCallback): void; function getFormsInfoByApp(bundleName: string): Promise; /** * get forms info by application name and module name. * *

You can use this method to get all forms info of the specify application name and module name.

* * @param bundleName application name. * @param moduleName module name of hap * @return Returns the forms' information of the specify application name and module name * @since 7 */ function getFormsInfoByModule(bundleName: string, moduleName: string, callback: AsyncCallback): void; function getFormsInfoByModule(bundleName: string, moduleName: string): Promise; on(type: "formUninstalled", formID: number, callback: AsyncCallback): void; off(type: "formUninstalled", formID: number, callback?: AsyncCallback): void; on(type: "getAnimation", callback: AsyncCallback): void; off(type: "getAnimation", callback?: AsyncCallback): void; export enum FromParam { /** * Indicates the key specifying the ID of the form to be obtained, which is represented as * {@code intent.setParam(PARAM_FORM_IDENTITY_KEY, 1L)}. */ IDENTITY_KEY = "ohos.extra.param.key.form_identity", /** * Indicates the form dimension, now value support 1,2,3,4. */ DIMENSION_KEY = "ohos.extra.param.key.form_dimension", /** * Indicates the form name. */ NAME_KEY = "ohos.extra.param.key.form_name", /** * Indicates the module name of the form. */ NAME_KEY = "ohos.extra.param.key.module_name", /** * Indicates the form view width. */ WIDTH_KEY = "ohos.extra.param.key.form_width", /** * Indicates the form view height. */ HEIGHT_KEY = "ohos.extra.param.key.form_height", /** * Indicates the temporary flag of form to be obtained */ TEMPORARY_KEY = "ohos.extra.param.key.form_temporary" } export enum FormError { ERR_CODE_COMMON = 1, ERR_PERMISSION_DENY = 2, ERR_GET_INFO_FAILED = 4, ERR_GET_BUNDLE_FAILED = 5, ERR_GET_LAYOUT_FAILED = 6, ERR_ADD_INVALID_PARAM = 7, ERR_CFG_NOT_MATCH_ID = 8, ERR_NOT_EXIST_ID = 9, ERR_BIND_PROVIDER_FAILED = 10, ERR_MAX_SYSTEM_FORMS = 11, ERR_MAX_INSTANCES_PER_FORM = 12, ERR_OPERATION_FORM_NOT_SELF = 13, ERR_PROVIDER_DEL_FAIL = 14, ERR_MAX_FORMS_PER_CLIENT = 15, ERR_MAX_SYSTEM_TEMP_FORMS = 16, ERR_FORM_NO_SUCH_MODULE = 17, ERR_FORM_NO_SUCH_ABILITY = 18, ERR_FORM_NO_SUCH_DIMENSION = 19, ERR_FORM_FA_NOT_INSTALLED = 20, // error code in sdk ERR_GET_FMS_RPC = 30, ERR_FORM_DUPLICATE_ADDED = 31, ERR_SEND_FMS_MSG = 32, ERR_GET_BMS_RPC = 33, ERR_SEND_BMS_MSG = 34, ERR_START_ABILITY = 35, ERR_IN_RECOVER = 36 } } export default formManager;