CreatePostEventTimeouter(std::string taskstr);
+
+ /**
+ * Releases an obtained form by its ID.
+ *
+ * After this method is called, the form won't be available for use by the application, but the Form Manager
+ * Service still keeps the cache information about the form, so that the application can quickly obtain it based on
+ * the {@code formId}.
+ * Permission: {@link ohos.security.SystemPermission#REQUIRE_FORM}
+ *
+ * @param formId Indicates the form ID.
+ * @return Returns {@code true} if the form is successfully released; returns {@code false} otherwise.
+ *
+ *
+ * - The passed {@code formId} is invalid. Its value must be larger than 0.
+ * - The specified form has not been added by the application.
+ * - An error occurred when connecting to the Form Manager Service.
+ * - The application is not granted with the {@link ohos.security.SystemPermission#REQUIRE_FORM} permission.
+ * - The form has been obtained by another application and cannot be released by the current application.
+ * - The form is being restored.
+ *
+ */
+ bool ReleaseForm(const int64_t formId);
+
+ /**
+ * @brief Releases an obtained form by its ID.
+ *
+ * After this method is called, the form won't be available for use by the application, if isReleaseCache is
+ * false, this method is same as {@link #releaseForm(int)}, otherwise the Form Manager Service still store this
+ * form in the cache.
+ * Permission: {@link ohos.security.SystemPermission#REQUIRE_FORM}
+ *
+ * @param formId Indicates the form ID.
+ * @param isReleaseCache Indicates whether to clear cache in service.
+ * @return Returns {@code true} if the form is successfully released; returns {@code false} otherwise.
+ *
+ *
+ * - The passed {@code formId} is invalid. Its value must be larger than 0.
+ * - The specified form has not been added by the application.
+ * - An error occurred when connecting to the Form Manager Service.
+ * - The application is not granted with the {@link ohos.security.SystemPermission#REQUIRE_FORM} permission.
+ * - The form has been obtained by another application and cannot be released by the current application.
+ * - The form is being restored.
+ *
+ */
+ bool ReleaseForm(const int64_t formId, const bool isReleaseCache);
+
+ /**
+ * @brief Deletes an obtained form by its ID.
+ *
+ * After this method is called, the form won't be available for use by the application and the Form Manager
+ * Service no longer keeps the cache information about the form.
+ * Permission: {@link ohos.security.SystemPermission#REQUIRE_FORM}
+ *
+ * @param formId Indicates the form ID.
+ * @return Returns {@code true} if the form is successfully deleted; returns {@code false} otherwise.
+ *
+ *
+ * - The passed {@code formId} is invalid. Its value must be larger than 0.
+ * - The specified form has not been added by the application.
+ * - An error occurred when connecting to the Form Manager Service.
+ * - The application is not granted with the {@link ohos.security.SystemPermission#REQUIRE_FORM} permission.
+ * - The form has been obtained by another application and cannot be deleted by the current application.
+ * - The form is being restored.
+ *
+ */
+ bool DeleteForm(const int64_t formId);
+
+ /**
+ * @brief The form callback.
+ */
+ class FormCallback {
+ public:
+ static const int32_t OHOS_FORM_ACQUIRE_SUCCESS = 0;
+ static const int32_t OHOS_FORM_UPDATE_SUCCESS = 0;
+ static const int32_t OHOS_FORM_PREVIEW_FAILURE = 1;
+ static const int32_t OHOS_FORM_RESTORE_FAILURE = 2;
+
+ /**
+ * @brief Called to notify the application that the {@code FormJsInfo} instance has been obtained after
+ * the application called the asynchronous method {@link Ability#acquireForm(Want, FormCallback)}.
+ * The application must present the form information on a specific page in this callback.
+ *
+ * @param result Specifies whether the asynchronous form acquisition process is successful.
+ * {@link FormCallback#OHOS_FORM_ACQUIRE_SUCCESS} indicates that the form
+ * is successfully obtained, and other values indicate that the process fails.
+ * @param formJsInfo Indicates the obtained {@code FormJsInfo} instance.
+ */
+ virtual void OnAcquired(const int32_t result, const FormJsInfo &formJsInfo) const = 0;
+
+ /**
+ * @brief Called to notify the application that the {@code FormJsInfo} instance has been obtained after
+ * the application called the asynchronous method {@link Ability#acquireForm(Want, FormCallback)}.
+ * The application must present the form information on a specific page in this callback.
+ *
+ * @param result Specifies whether the asynchronous form acquisition process is successful.
+ * {@link FormCallback#OHOS_FORM_UPDATE_SUCCESS} indicates that the form is
+ * successfully obtained, and other values indicate that the process fails.
+ * @param formJsInfo Indicates the obtained {@code FormJsInfo} instance.
+ */
+ virtual void OnUpdate(const int32_t result, const FormJsInfo &formJsInfo) const = 0;
+
+ /**
+ * @brief Called to notify the application that the {@code Form} provider has been uninstalled and the
+ * corresponding
+ * {@code Form} instance is no longer available.
+ *
+ * @param formId Indicates the ID of the {@code Form} instance provided by the uninstalled form provider.
+ */
+ virtual void OnFormUninstall(const int64_t formId) const = 0;
+ };
+
+ /**
+ * @brief Obtains a specified form that matches the application bundle name, module name, form name, and
+ * other related information specified in the passed {@code Want}.
+ *
+ * This method is asynchronous. After the {@link FormJsInfo} instance is obtained.
+ *
+ * @param formId Indicates the form ID.
+ * @param want Indicates the detailed information about the form to be obtained, including the bundle name,
+ * module name, ability name, form name, form id, tempForm flag, form dimension, and form customize data.
+ * @param callback Indicates the callback to be invoked whenever the {@link FormJsInfo} instance is obtained.
+ * @return Returns {@code true} if the request is successfully initiated; returns {@code false} otherwise.
+ */
+ bool AcquireForm(const int64_t formId, const Want &want, const std::shared_ptr callback);
+
+ /**
+ * @brief 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 form ID.
+ * @param formProviderData The data used to update the JS form displayed on the client.
+ * @return Returns {@code true} if the request is successfully initiated; returns {@code false} otherwise.
+ */
+ bool UpdateForm(const int64_t formId, const FormProviderData &formProviderData);
+
+ /**
+ * @brief Cast temp form with formId.
+ *
+ * @param formId Indicates the form's ID.
+ *
+ * @return Returns {@code true} if the form is successfully casted; returns {@code false} otherwise.
+ */
+ bool CastTempForm(const int64_t formId);
+
+ /**
+ * @brief Sends a notification to the form framework to make the specified forms visible.
+ *
+ *
After this method is successfully called, {@link Ability#OnVisibilityChanged(std::map)}
+ * will be called to notify the form provider of the form visibility change event.
+ *
+ * @param formIds Indicates the IDs of the forms to be made visible.
+ * @return Returns {@code true} if the request is successfully initiated; returns {@code false} otherwise.
+ */
+ bool NotifyVisibleForms(const std::vector &formIds);
+
+ /**
+ * @brief Sends a notification to the form framework to make the specified forms invisible.
+ *
+ * After this method is successfully called, {@link Ability#OnVisibilityChanged(std::map)}
+ * will be called to notify the form provider of the form visibility change event.
+ *
+ * @param formIds Indicates the IDs of the forms to be made invisible.
+ * @return Returns {@code true} if the request is successfully initiated; returns {@code false} otherwise.
+ */
+ bool NotifyInvisibleForms(const std::vector &formIds);
+
+ /**
+ * @brief Set form next refresh time.
+ *
+ * This method is called by a form provider to set refresh time.
+ *
+ * @param formId Indicates the ID of the form to set refresh time.
+ * @param nextTime Indicates the next time gap now in seconds, can not be litter than 300 seconds.
+ * @return Returns {@code true} if seting succeed; returns {@code false} otherwise.
+ */
+
+ bool SetFormNextRefreshTime(const int64_t formId, const int64_t nextTime);
+
+ /**
+ * @brief Update form.
+ *
+ * @param formJsInfo Indicates the obtained {@code FormJsInfo} instance.
+ */
+ void ProcessFormUpdate(const FormJsInfo &formJsInfo) override;
+
+ /**
+ * @brief Uninstall form.
+ *
+ * @param formId Indicates the ID of the form to uninstall.
+ */
+ void ProcessFormUninstall(const int64_t formId) override;
+
+ /**
+ * @brief Called to reacquire form and update the form host after the death callback is received.
+ *
+ */
+ void OnDeathReceived() override;
+
+ /**
+ * @brief Called to return a FormProviderInfo object.
+ *
+ *
You must override this method if your ability will serve as a form provider to provide a form for clients.
+ * The default implementation returns nullptr.
+ *
+ * @param want Indicates the detailed information for creating a FormProviderInfo.
+ * The Want object must include the form ID, form name of the form,
+ * which can be obtained from Ability#PARAM_FORM_IDENTITY_KEY,
+ * Ability#PARAM_FORM_NAME_KEY, and Ability#PARAM_FORM_DIMENSION_KEY,
+ * respectively. Such form information must be managed as persistent data for further form
+ * acquisition, update, and deletion.
+ *
+ * @return Returns the created FormProviderInfo object.
+ */
+ virtual FormProviderInfo OnCreate(const Want &want);
+
+ /**
+ * @brief Called to notify the form provider that a specified form has been deleted. Override this method if
+ * you want your application, as the form provider, to be notified of form deletion.
+ *
+ * @param formId Indicates the ID of the deleted form.
+ * @return None.
+ */
+ virtual void OnDelete(const int64_t formId);
+
+ /**
+ * @brief Called when the form provider is notified that a temporary form is successfully converted to
+ * a normal form.
+ *
+ * @param formId Indicates the ID of the form.
+ * @return None.
+ */
+ virtual void OnCastTemptoNormal(const int64_t formId);
+
+ /**
+ * @brief Called to notify the form provider to update a specified form.
+ *
+ * @param formId Indicates the ID of the form to update.
+ * @return none.
+ */
+ virtual void OnUpdate(const int64_t formId);
+
+ /**
+ * @brief Called when the form provider receives form events from the fms.
+ *
+ * @param formEventsMap Indicates the form events occurred. The key in the Map object indicates the form ID,
+ * and the value indicates the event type, which can be either FORM_VISIBLE
+ * or FORM_INVISIBLE. FORM_VISIBLE means that the form becomes visible,
+ * and FORM_INVISIBLE means that the form becomes invisible.
+ * @return none.
+ */
+ virtual void OnVisibilityChanged(const std::map &formEventsMap);
+ /**
+ * @brief Called to notify the form provider to update a specified form.
+ *
+ * @param formId Indicates the ID of the form to update.
+ * @param message Form event message.
+ */
+ virtual void OnTriggerEvent(const int64_t formId, const std::string &message);
+ /**
+ * @brief Requests for form data update.
+ *
+ * This method must be called when the application has detected that a system setting item (such as the language,
+ * resolution, or screen orientation) being listened for has changed. Upon receiving the update request, the form
+ * provider automatically updates the form data (if there is any update) through the form framework, with the update
+ * process being unperceivable by the application.
+ *
+ * @param formId Indicates the ID of the form to update.
+ * @return Returns true if the update request is successfully initiated, returns false otherwise.
+ */
+ bool RequestForm(const int64_t formId);
+
+ /**
+ * @brief Requests for form data update, by passing a set of parameters (using Want) to the form provider.
+ *
+ * This method must be called when the application has detected that a system setting item (such as the language,
+ * resolution, or screen orientation) being listened for has changed. Upon receiving the update request, the form
+ * provider automatically updates the form data (if there is any update) through the form framework, with the update
+ * process being unperceivable by the application.
+ *
+ * @param formId Indicates the ID of the form to update.
+ * @param want Indicates a set of parameters to be transparently passed to the form provider.
+ * @return Returns true if the update request is successfully initiated, returns false otherwise.
+ */
+ bool RequestForm(const int64_t formId, const Want &want);
+ /**
+ * @brief Enable form update.
+ *
+ * @param formIds formIds of hostclient.
+ */
+ bool EnableUpdateForm(const std::vector &formIds);
+
+ /**
+ * @brief Disable form update.
+ *
+ * @param formIds formIds of hostclient.
+ */
+ bool DisableUpdateForm(const std::vector &formIds);
+
+ /**
+ * @brief Check form manager service ready.
+ *
+ * @return Returns true if form manager service ready; returns false otherwise.
+ */
+ bool CheckFMSReady();
+
+ /**
+ * @brief Get All FormsInfo.
+ *
+ * @param formInfos Returns the forms' information of all forms provided.
+ * @return Returns true if the request is successfully initiated; returns false otherwise.
+ */
+ bool GetAllFormsInfo(std::vector &formInfos);
+
+ /**
+ * @brief Get forms info by application name.
+ *
+ * @param bundleName Application name.
+ * @param formInfos Returns the forms' information of the specify application name.
+ * @return Returns true if the request is successfully initiated; returns false otherwise.
+ */
+ bool GetFormsInfoByApp(std::string &bundleName, std::vector &formInfos);
+
+ /**
+ * @brief Get forms info by application name and module name.
+ *
+ * @param bundleName Application name.
+ * @param moduleName Module name of hap.
+ * @param formInfos Returns the forms' information of the specify application name and module name.
+ * @return Returns true if the request is successfully initiated; returns false otherwise.
+ */
+ bool GetFormsInfoByModule(std::string &bundleName, std::string &moduleName, std::vector &formInfos);
+
+ /**
+ * @brief Acquire a bundle manager, if it not existed,
+ * @return returns the bundle manager ipc object, or nullptr for failed.
+ */
+ sptr GetBundleMgr();
+
+ /**
+ * @brief check permission of bundle, if it not existed.
+ * @return returns the permission is vaild, or false for failed.
+ */
+ bool CheckPermission();
+
+ /**
+ * @brief Permission check.
+ * @param bundleName bundleName.
+ * @return Returns true on success, false on failure.
+ */
+ bool CheckFormPermission(const std::string &bundleName) const;
+
+ /**
+ * @brief Add the bundle manager instance for debug.
+ * @param bundleManager the bundle manager ipc object.
+ */
+ void SetBundleManager(const sptr &bundleManager);
+
+ /**
+ * @brief You can use the IContinuationRegisterManager object to interact with the Device+ control center,
+ * including registering and unregistering the ability to migrate, updating the device connection state, and
+ * showing the list of devices that can be selected for ability migration.
+ *
+ * @return Returns true if the migration request is successful; returns false otherwise.
+ */
+ std::weak_ptr GetContinuationRegisterManager();
+
+ /**
+ * @brief Migrates this ability to the given device on the same distributed network. The ability to migrate and its
+ * ability slices must implement the IAbilityContinuation interface.
+ *
+ * @param deviceId Indicates the ID of the target device where this ability will be migrated to. If this parameter
+ * is null, this method has the same effect as continueAbility().
+ *
+ */
+ virtual void ContinueAbility(const std::string &deviceId) final;
+
+ /**
+ * @brief Callback function to ask the user whether to start the migration .
+ *
+ * @return If the user allows migration, it returns true; otherwise, it returns false.
+ */
+ virtual bool OnStartContinuation() override;
+
+ /**
+ * @brief Performs batch operations on the database.
+ *
+ * @param operations Indicates a list of database operations on the database.
+ * @return Returns the result of each operation, in array.
+ */
+ virtual std::vector> ExecuteBatch(
+ const std::vector> &operations);
+
+ /**
+ * @brief Executes an operation among the batch operations to be executed.
+ *
+ * @param operation Indicates the operation to execute.
+ * @param results Indicates a set of results of the batch operations.
+ * @param index Indicates the index of the current operation result in the batch operation results.
+ */
+ void ExecuteOperation(std::shared_ptr &operation,
+ std::vector> &results, int index);
+
+ /**
+ * @brief Save user data of local Ability generated at runtime.
+ *
+ * @param saveData Indicates the user data to be saved.
+ * @return If the data is saved successfully, it returns true; otherwise, it returns false.
+ */
+ virtual bool OnSaveData(WantParams &saveData) override;
+
+ /**
+ * @brief After creating the Ability on the remote device,
+ * immediately restore the user data saved during the migration of the Ability on the remote device.
+ * @param restoreData Indicates the user data to be restored.
+ * @return If the data is restored successfully, it returns true; otherwise, it returns false .
+ */
+ virtual bool OnRestoreData(WantParams &restoreData) override;
+
+ /**
+ * @brief This function can be used to implement the processing logic after the migration is completed.
+ *
+ * @param result Migration result code. 0 means the migration was successful, -1 means the migration failed.
+ * @return None.
+ */
+ virtual void OnCompleteContinuation(int result) override;
+
+ /**
+ * @brief Used to notify the local Ability that the remote Ability has been destroyed.
+ *
+ * @return None.
+ */
+ virtual void OnRemoteTerminated() override;
+
+protected:
+ /**
+ * @brief Acquire a form provider remote object.
+ * @return Returns form provider remote object.
+ */
+ sptr GetFormRemoteObject();
+
+private:
+ std::shared_ptr ParsePredictionArgsReference(
+ std::vector> &results, std::shared_ptr &operation,
+ int numRefs);
+
+ std::shared_ptr ParseValuesBucketReference(
+ std::vector> &results, std::shared_ptr &operation,
+ int numRefs);
+
+ int ChangeRef2Value(std::vector> &results, int numRefs, int index);
+
+ bool CheckAssertQueryResult(std::shared_ptr &queryResult,
+ std::shared_ptr &&valuesBucket);
+
+ friend class AbilityImpl;
+ bool VerifySupportForContinuation();
+ void HandleCreateAsContinuation(const Want &want);
+ bool IsFlagExists(unsigned int flag, unsigned int flagSet);
+ /**
+ * @brief Set the start ability setting.
+ * @param setting the start ability setting.
+ */
+ void SetStartAbilitySetting(std::shared_ptr setting);
+
private:
+ std::shared_ptr continuationHandler_ = nullptr;
+ std::shared_ptr continuationManager_ = nullptr;
+ std::shared_ptr continuationRegisterManager_ = nullptr;
std::shared_ptr abilityInfo_ = nullptr;
- std::shared_ptr context_;
- std::shared_ptr handler_;
+ std::shared_ptr context_ = nullptr;
+ std::shared_ptr handler_ = nullptr;
std::shared_ptr lifecycle_ = nullptr;
std::shared_ptr abilityLifecycleExecutor_ = nullptr;
- std::shared_ptr application_;
+ std::shared_ptr application_ = nullptr;
std::vector types_;
std::shared_ptr abilityWindow_ = nullptr;
- std::shared_ptr setWant_;
+ std::shared_ptr setWant_ = nullptr;
+ sptr reverseContinuationSchedulerReplica_ = nullptr;
+ std::shared_ptr setting_ = nullptr;
bool bWindowFocus_ = false;
static const std::string SYSTEM_UI;
static const std::string STATUS_BAR;
static const std::string NAVIGATION_BAR;
+ sptr providerRemoteObject_ = nullptr;
+ // Keep consistent with DMS defines. Used to callback to DMS.
+ static const std::string DMS_SESSION_ID;
+
+ // The originating deviceId passed by DMS using intent param.
+ static const std::string DMS_ORIGIN_DEVICE_ID;
+
+ // If session id cannot get from intent, assign it as default.
+ static const int DEFAULT_DMS_SESSION_ID;
+
+ std::vector lostedByReconnectTempForms_;
+ std::map> appCallbacks_;
+ std::map userReqParams_;
+ sptr iBundleMgr_;
+
+ static const int32_t OHOS_FORM_ACQUIRE_FORM = 0;
+ static const int32_t OHOS_FORM_UPDATE_FORM = 1;
+
+ static const int32_t DELETE_FORM = 3;
+ static const int32_t ENABLE_FORM_UPDATE = 5;
+ static const int32_t DISABLE_FORM_UPDATE = 6;
+ static const int32_t RELEASE_FORM = 8;
+ static const int32_t RELEASE_CACHED_FORM = 9;
+ static const int64_t MIN_NEXT_TIME = 5;
+
+private:
+ /**
+ * @brief Delete or release form with formId.
+ *
+ * @param formId Indicates the form's ID.
+ * @param deleteType Indicates the type of delete or release.
+ * @return Returns {@code true} if the form is successfully deleted; returns {@code false} otherwise.
+ */
+ bool DeleteForm(const int64_t formId, const int32_t deleteType);
+
+ /**
+ * @brief Clean form resource with formId.
+ *
+ * @param formId Indicates the form's ID.
+ */
+ void CleanFormResource(const int64_t formId);
+
+ /**
+ * @brief Handle acquire result of the obtained form instance.
+ *
+ * @param want Indicates the detailed information about the form to be obtained, including the bundle name,
+ * module name, ability name, form name, form id, tempForm flag, form dimension, and form customize data.
+ * @param formJsInfo Indicates the obtained {@code FormJsInfo} instance.
+ * @param callback Indicates the callback to be invoked whenever the {@link FormJsInfo} instance is obtained.
+ */
+ void HandleAcquireResult(
+ const Want &want,
+ const FormJsInfo &formJsInfo,
+ const std::shared_ptr callback
+ );
+
+ /**
+ * @brief Handle acquire message of the obtained form instance.
+ *
+ * @param msgCode Indicates the code of message type.
+ * @param formJsInfo Indicates the obtained {@code FormJsInfo} instance.
+ */
+ void HandleFormMessage(const int32_t msgCode, const FormJsInfo &formJsInfo);
+
+ /**
+ * @brief Notify the forms visibility change event.
+ *
+ * @param formIds Indicates the IDs of the forms to be made visible or invisible.
+ * @param eventType Indicates the form events occurred. FORM_VISIBLE means that the form becomes visible,
+ * and FORM_INVISIBLE means that the form becomes invisible.
+ * @return none.
+ */
+ bool NotifyWhetherVisibleForms(const std::vector &formIds, int32_t eventType);
+
+ /**
+ * @brief Check the param of want.
+ *
+ * @param formId Indicates the form's ID.
+ * @param want Indicates the detailed information about the form to be obtained, including the bundle name,
+ * module name, ability name, form name, form id, tempForm flag, form dimension, and form customize data.
+ * @return Returns {@code true} if the check result is ok; returns {@code false} ng.
+ */
+ bool CheckWantValid(const int64_t formId, const Want &want);
+
+ /**
+ * @brief Handle enable/disable form update.
+ *
+ * @param formIds Indicates the IDs of the forms to be made visible.
+ * @param updateType Update type.
+ * @return Returns true if the result is ok; returns false otherwise.
+ */
+ bool LifecycleUpdate(std::vector formIds, int32_t updateType);
+
+ /**
+ * @brief Reacquire a specified form when the death callback is received.
+ *
+ * @param formId Indicates the form ID.
+ * @param want Indicates the detailed information about the form to be obtained.
+ * @return Returns true if the request is successfully initiated; returns false otherwise.
+ */
+ bool ReAcquireForm(const int64_t formId, const Want &want);
};
+
} // namespace AppExecFwk
} // namespace OHOS
#endif // FOUNDATION_APPEXECFWK_OHOS_ABILITY_H
diff --git a/frameworks/kits/ability/native/include/ability_context.h b/frameworks/kits/ability/native/include/ability_context.h
index dbabf9976952a48e5e4c4190f6c04a4c8cdca61b..121de7fe2c2d8826583c37a2af6f816449f69e47 100755
--- a/frameworks/kits/ability/native/include/ability_context.h
+++ b/frameworks/kits/ability/native/include/ability_context.h
@@ -16,6 +16,8 @@
#ifndef FOUNDATION_APPEXECFWK_OHOS_ABILITY_CONTEXT_H
#define FOUNDATION_APPEXECFWK_OHOS_ABILITY_CONTEXT_H
+#include