diff --git a/BUILD.gn b/BUILD.gn index e2a69934bf9735dce117cb36b1833e30cb89623b..14d72e62e920c1ded7964ba8eee56650cbf589e2 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -60,6 +60,7 @@ ohos_shared_library("libfms") { "services/src/form_mgr_adapter.cpp", "services/src/form_mgr_service.cpp", "services/src/form_msg_event_connection.cpp", + "services/src/form_notify_size_changed_connection.cpp", "services/src/form_provider_mgr.cpp", "services/src/form_refresh_connection.cpp", "services/src/form_refresh_limiter.cpp", diff --git a/frameworks/js/napi/formHost/napi_form_host.cpp b/frameworks/js/napi/formHost/napi_form_host.cpp index 1eb305cebfb20ddc2fcab6778295168fbf374081..bd9497971b52dd60f61cf82bc8f55c4e1392884e 100644 --- a/frameworks/js/napi/formHost/napi_form_host.cpp +++ b/frameworks/js/napi/formHost/napi_form_host.cpp @@ -3442,6 +3442,64 @@ void JsFormHost::InnerShareForm( FormHostClient::GetInstance()->RemoveShareFormCallback(requestCode); } } + +NativeValue* JsFormHost::ResizeForm(NativeEngine* engine, NativeCallbackInfo* info) +{ + JsFormHost* me = OHOS::AbilityRuntime::CheckParamsAndGetThis(engine, info); + return (me != nullptr) ? me->OnResizeForm(*engine, *info) : nullptr; +} + +NativeValue* JsFormHost::OnResizeForm(NativeEngine &engine, NativeCallbackInfo &info) +{ + HILOG_DEBUG("OnResizeForm is called"); + int32_t errCode = ERR_OK; + if (info.argc > ARGS_SIZE_THREE || info.argc < ARGS_SIZE_TWO) { + HILOG_ERROR("%{public}s, wrong number of arguments.", __func__); + errCode = ERR_ADD_INVALID_PARAM; + } + + std::string strFormId = + GetStringFromNAPI(reinterpret_cast(&engine), reinterpret_cast(info.argv[0])); + std::string strDimensionId = + GetStringFromNAPI(reinterpret_cast(&engine), reinterpret_cast(info.argv[1])); + // The promise form has only two parameters + decltype(info.argc) unwrapArgc = 2; + + int64_t formId = 0; + int64_t dimensionNum = 0; + if (!ConvertStringToInt64(strFormId, formId) || !ConvertStringToInt64(strDimensionId, dimensionNum)) { + HILOG_ERROR("Convert string formId to int64 failed."); + errCode = ERR_COMMON; + } + int32_t dimensionId = dimensionNum; + if (formId == 0 || dimensionId < 0) { + errCode = ERR_COMMON; + } + + AbilityRuntime::AsyncTask::CompleteCallback complete = + [formId, dimensionId, errCode](NativeEngine &engine, AbilityRuntime::AsyncTask &task, int32_t status) { + if (errCode != ERR_OK) { + task.Reject(engine, CreateJsError(engine, errCode, QueryRetMsg(errCode))); + return; + } + + auto ret = FormMgr::GetInstance().NotifyFormSizeChanged(formId, + dimensionId, FormHostClient::GetInstance()); + if (ret == ERR_OK) { + task.Resolve(engine, engine.CreateUndefined()); + } else { + auto retCode = QueryRetCode(ret); + task.Reject(engine, CreateJsError(engine, retCode, QueryRetMsg(retCode))); + } + }; + + NativeValue* lastParam = (info.argc <= unwrapArgc) ? nullptr : info.argv[unwrapArgc]; + NativeValue* result = nullptr; + + AsyncTask::Schedule("JsFormHost::OnResizeForm", + engine, CreateAsyncTaskWithLastParam(engine, lastParam, nullptr, std::move(complete), &result)); + return result; +} } // namespace AbilityRuntime } // namespace OHOS diff --git a/frameworks/js/napi/formHost/napi_form_host.h b/frameworks/js/napi/formHost/napi_form_host.h index 134ae0c6f7e5cce675580394ebdfdf4990c69d52..4ee3b608986b0aa130b04e5e95060106225a4d99 100644 --- a/frameworks/js/napi/formHost/napi_form_host.h +++ b/frameworks/js/napi/formHost/napi_form_host.h @@ -184,10 +184,12 @@ public: static void Finalizer(NativeEngine* engine, void* data, void* hint); static NativeValue* ShareForm(NativeEngine* engine, NativeCallbackInfo* info); + static NativeValue* ResizeForm(NativeEngine* engine, NativeCallbackInfo* info); private: NativeValue* OnShareForm(NativeEngine &engine, NativeCallbackInfo &info); void InnerShareForm(NativeEngine &engine, const std::shared_ptr &asyncTask, ShareFormTask &&task, int64_t formId, const std::string &remoteDeviceId); + NativeValue* OnResizeForm(NativeEngine &engine, NativeCallbackInfo &info); }; } // namespace AbilityRuntime } // namespace OHOS diff --git a/frameworks/js/napi/formHost/native_module.cpp b/frameworks/js/napi/formHost/native_module.cpp index 9ce8025af1c974fc5763a82627a92fa90989988b..4577abf3b57c1c3201271b36a9ad49bba2c8948a 100644 --- a/frameworks/js/napi/formHost/native_module.cpp +++ b/frameworks/js/napi/formHost/native_module.cpp @@ -46,6 +46,8 @@ static NativeValue* JsFormHostInit(NativeEngine* engine, NativeValue* exports) const char *moduleName = "JsFormHost"; OHOS::AbilityRuntime::BindNativeFunction(*engine, *object, "shareForm", moduleName, JsFormHost::ShareForm); + OHOS::AbilityRuntime::BindNativeFunction(*engine, *object, "NotifyFormSizeChange", + moduleName, JsFormHost::ResizeForm); return exports; } diff --git a/interfaces/inner_api/include/form_constants.h b/interfaces/inner_api/include/form_constants.h index 110177aa926417c8b219a18341fbcde14891329c..2a48e12a2f078ad085a48d41b8ffa10a6cd93538 100644 --- a/interfaces/inner_api/include/form_constants.h +++ b/interfaces/inner_api/include/form_constants.h @@ -129,7 +129,7 @@ namespace Constants { {5, "2*1"} }; constexpr int32_t DIM_KEY_MIN = 1; - constexpr int32_t DIM_KEY_MAX = 4; + constexpr int32_t DIM_KEY_MAX = 5; constexpr int32_t MAX_FORMS = 512; constexpr int32_t MAX_RECORD_PER_APP = 256; constexpr int32_t MAX_TEMP_FORMS = 256; @@ -148,6 +148,7 @@ namespace Constants { constexpr const char* ACQUIRE_TYPE = "form_acquire_form"; constexpr int32_t ACQUIRE_TYPE_CREATE_FORM = 1; constexpr int32_t ACQUIRE_TYPE_RECREATE_FORM = 2; + constexpr int32_t ACQUIRE_TYPE_RESIZE_FORM = 3; constexpr int32_t DELETE_FORM = 3; constexpr int32_t RELEASE_FORM = 8; diff --git a/interfaces/inner_api/include/form_host_interface.h b/interfaces/inner_api/include/form_host_interface.h index c8ad68df9b61b34fdaa52043c32db8797d106366..d1ec031f046f01e25f0109c2f64a428e0707784e 100644 --- a/interfaces/inner_api/include/form_host_interface.h +++ b/interfaces/inner_api/include/form_host_interface.h @@ -65,6 +65,13 @@ public: * @param result Share form result. */ virtual void OnShareFormResponse(int64_t requestCode, int32_t result) = 0; + + /** + * @brief Request to give back a Form after size changed. + * @param formInfo Form info. + */ + virtual void OnSizeChanged(const FormJsInfo &formInfo) = 0; + enum class Message { // ipc id 1-1000 for kit // ipc id 1001-2000 for DMS @@ -83,6 +90,9 @@ public: // ipc id for share form response(3685) FORM_HOST_ON_SHARE_FORM_RESPONSE, + + // ipc id for change form size(3686) + FORM_HOST_ON_SIZE_CHANGED, }; }; } // namespace AppExecFwk diff --git a/interfaces/inner_api/include/form_host_proxy.h b/interfaces/inner_api/include/form_host_proxy.h index aab45717f813f015721c88e81f61fb355ed0221c..192d9c7f3a5b4dcd97c774c6c7786bce7d725ee8 100644 --- a/interfaces/inner_api/include/form_host_proxy.h +++ b/interfaces/inner_api/include/form_host_proxy.h @@ -66,6 +66,13 @@ public: * @param result Share form result. */ void OnShareFormResponse(int64_t requestCode, int32_t result) override; + + /** + * @brief Request to give back a Form after size changed. + * @param formInfo Form info. + */ + void OnSizeChanged(const FormJsInfo &formInfo) override; + private: template int GetParcelableInfos(MessageParcel &reply, std::vector &parcelableInfos); diff --git a/interfaces/inner_api/include/form_host_stub.h b/interfaces/inner_api/include/form_host_stub.h index 698963c47469fc8237373f088e309260187c7184..5b9220bdf04d08b89c04f330467914cfd5b39854 100644 --- a/interfaces/inner_api/include/form_host_stub.h +++ b/interfaces/inner_api/include/form_host_stub.h @@ -80,6 +80,14 @@ private: * @return Returns ERR_OK on success, others on failure. */ int32_t HandleOnShareFormResponse(MessageParcel &data, MessageParcel &reply); + + /** + * @brief handle OnSizeChanged message. + * @param data input param. + * @param reply output param. + * @return Returns ERR_OK on success, others on failure. + */ + ErrCode HandleOnSizeChanged(MessageParcel &data, MessageParcel &reply); private: using FormHostFunc = int32_t (FormHostStub::*)(MessageParcel &data, MessageParcel &reply); std::map memberFuncMap_; diff --git a/interfaces/inner_api/include/form_js_info.h b/interfaces/inner_api/include/form_js_info.h index 80a8cad396adb84e65bf7bd2aa636f5136c1ed5b..5fdd5029197cca3b1684f507a7fe170a8ccf0f5f 100644 --- a/interfaces/inner_api/include/form_js_info.h +++ b/interfaces/inner_api/include/form_js_info.h @@ -39,6 +39,7 @@ struct FormJsInfo : public Parcelable { std::string formData; std::map> imageDataMap; FormProviderData formProviderData; + int32_t specification; std::string formSrc; FormWindow formWindow; uint32_t versionCode = 0; diff --git a/interfaces/inner_api/include/form_mgr_interface.h b/interfaces/inner_api/include/form_mgr_interface.h index 648f25990e305fcc9ec57cc0fb05257473d57c20..0b70796e98629103b3d6519bdab517bec73e1599 100644 --- a/interfaces/inner_api/include/form_mgr_interface.h +++ b/interfaces/inner_api/include/form_mgr_interface.h @@ -333,6 +333,17 @@ public: * @return Returns ERR_OK on success, others on failure. */ virtual int32_t RecvFormShareInfoFromRemote(const FormShareInfo &info) = 0; + + /** + * @brief notify form rto change size with formId and newDimension, + * send formId and new Dimension to form manager service. + * @param formId The Id of the forms to delete. + * @param newDimension the newDimension of the form to reSize + * @param callerToken Caller ability token. + * @return Returns ERR_OK on success, others on failure. + */ + virtual int NotifyFormSizeChanged(int64_t formId, int32_t dimensionNum, + const sptr &callerToken) = 0; enum class Message { // ipc id 1-1000 for kit @@ -378,6 +389,7 @@ public: FORM_MGR_SHARE_FORM, FORM_MGR_RECV_FORM_SHARE_INFO_FROM_REMOTE, FORM_MGR_START_ABILITY, + FORM_MGR_NOTIFY_FORM_SIZE_CHANGED, }; }; } // namespace AppExecFwk diff --git a/interfaces/inner_api/include/form_mgr_proxy.h b/interfaces/inner_api/include/form_mgr_proxy.h index 3c37b2931f73fe0a165e3db6116752ac291f1ed6..bcab6474a1430df36c3dd28d99bb062fa3c9ecb5 100644 --- a/interfaces/inner_api/include/form_mgr_proxy.h +++ b/interfaces/inner_api/include/form_mgr_proxy.h @@ -286,6 +286,17 @@ public: */ int32_t GetFormsInfo(const FormInfoFilter &filter, std::vector &formInfos) override; + /** + * @brief notify form change size with formId and newDimension, + * send formId and new Dimension to form manager service. + * @param formId The Id of the forms to delete. + * @param newDimension the newDimension of the form to reSize + * @param callerToken Caller ability token. + * @return Returns ERR_OK on success, others on failure. + */ + ErrCode NotifyFormSizeChanged(int64_t formId, int32_t dimensionNum, + const sptr &callerToken) override; + /** * @brief Check if the request of publishing a form is supported by the host. * @return Returns true if the request is supported and false otherwise. diff --git a/interfaces/inner_api/include/form_mgr_stub.h b/interfaces/inner_api/include/form_mgr_stub.h index af888a78e0b2d8a442182cc590454dcf468b4c24..8ec9a725a48090446cb92f50dad98ba45aebbc22 100644 --- a/interfaces/inner_api/include/form_mgr_stub.h +++ b/interfaces/inner_api/include/form_mgr_stub.h @@ -301,6 +301,14 @@ private: */ int32_t HandleStartAbility(MessageParcel &data, MessageParcel &reply); + /** + * @brief Handle NotifyFormSizeChanged message. + * @param data input param. + * @param reply output param. + * @return Returns ERR_OK on success, others on failure. + */ + ErrCode HandleNotifyFormSizeChanged(MessageParcel &data, MessageParcel &reply); + private: using FormMgrFunc = int32_t (FormMgrStub::*)(MessageParcel &data, MessageParcel &reply); std::map memberFuncMap_; diff --git a/interfaces/inner_api/include/form_provider_interface.h b/interfaces/inner_api/include/form_provider_interface.h index 583a174b84036633f28da8a13b80b2e4e0d216cf..2a77e61ab9ad5072af8388bec6df772e30dcfa9c 100644 --- a/interfaces/inner_api/include/form_provider_interface.h +++ b/interfaces/inner_api/include/form_provider_interface.h @@ -114,6 +114,16 @@ public: */ virtual int AcquireState(const Want &wantArg, const std::string &provider, const Want &want, const sptr &callerToken) = 0; + + /** + * @brief Notify provider when the form want to change the size. + * @param formId The Id of the form to update. + * @param want the want of the request containing the new formDimensionNum. + * @param callerToken Caller ability token. + * @return Returns ERR_OK on success, others on failure. + */ + virtual int NotifyFormSizeChanged(int64_t formId, const Want &want, + const sptr &callerToken) = 0; /** * @brief Acquire to share form information data. This is sync API. @@ -156,6 +166,9 @@ public: // ipc id for Acquire provider share form info (3059) FORM_ACQUIRE_PROVIDER_SHARE_FOMR_INFO, + + // ipc id for notifying the form size change (3060) + FORM_PROVIDER_NOTIFY_FORM_SIZE_CHANGE, }; }; } // namespace AppExecFwk diff --git a/interfaces/inner_api/include/form_provider_proxy.h b/interfaces/inner_api/include/form_provider_proxy.h index d31c1122bdbe0e4ef7afe184d959f6873166be84..a41f9a2d7f8d9687aca2c7b6415338ab18570b53 100644 --- a/interfaces/inner_api/include/form_provider_proxy.h +++ b/interfaces/inner_api/include/form_provider_proxy.h @@ -115,6 +115,16 @@ public: */ virtual int AcquireState(const Want &wantArg, const std::string &provider, const Want &want, const sptr &callerToken) override; + + /** + * @brief Notify provider when the form want to change the size. + * @param formId The Id of the form to update. + * @param want the want of the request containing the new form dimensionNum. + * @param callerToken Caller ability token. + * @return Returns ERR_OK on success, others on failure. + */ + ErrCode NotifyFormSizeChanged(int64_t formId, const Want &want, + const sptr &callerToken) override; /** * @brief Acquire to share form information data. This is sync API. diff --git a/interfaces/inner_api/include/form_provider_stub.h b/interfaces/inner_api/include/form_provider_stub.h index 76533c78c5e547b46674bcd54007b3c51c7bc9a2..455d5d05c4e9bf8d67f572d35fb99db097b30339 100644 --- a/interfaces/inner_api/include/form_provider_stub.h +++ b/interfaces/inner_api/include/form_provider_stub.h @@ -104,11 +104,16 @@ private: /** * @brief Handle request provider share form info message. + */ + int32_t HandleAcquireShareFormData(MessageParcel &data, MessageParcel &reply); + + /** + * @brief handle the form size change. * @param data input param. * @param reply output param. * @return Returns ERR_OK on success, others on failure. */ - int32_t HandleAcquireShareFormData(MessageParcel &data, MessageParcel &reply); + ErrCode HandleNotifyFormSizeChaned(MessageParcel &data, MessageParcel &reply); private: using FormProviderFunc = int32_t (FormProviderStub::*)(MessageParcel &data, MessageParcel &reply); std::map memberFuncMap_; diff --git a/interfaces/inner_api/src/form_host_proxy.cpp b/interfaces/inner_api/src/form_host_proxy.cpp index 9dc128399bfebfe7aec5181d43aad2cb1f9967f7..71609c58d432a4d4dc75da388f6b633dd1a6e9f5 100644 --- a/interfaces/inner_api/src/form_host_proxy.cpp +++ b/interfaces/inner_api/src/form_host_proxy.cpp @@ -81,6 +81,29 @@ void FormHostProxy::OnUpdate(const FormJsInfo &formInfo) } } +void FormHostProxy::OnSizeChanged(const FormJsInfo &formInfo) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!WriteInterfaceToken(data)) { + HILOG_ERROR("failed to write interface token"); + } + + if (!data.WriteParcelable(&formInfo)) { + HILOG_ERROR("failed to write formInfo"); + } + + ErrCode error = Remote()->SendRequest( + static_cast(IFormHost::Message::FORM_HOST_ON_SIZE_CHANGED), + data, + reply, + option); + if (error != ERR_OK) { + HILOG_ERROR("failed to SendRequest: %{public}d", error); + } +} /** * @brief Form provider is uninstalled diff --git a/interfaces/inner_api/src/form_host_stub.cpp b/interfaces/inner_api/src/form_host_stub.cpp index 5a66913c9eafaa75a6974686c6a29ef55c0bea14..db3cb246f1902c0847a3e5bc30cbb17af8a6f91b 100644 --- a/interfaces/inner_api/src/form_host_stub.cpp +++ b/interfaces/inner_api/src/form_host_stub.cpp @@ -38,6 +38,8 @@ FormHostStub::FormHostStub() &FormHostStub::HandleOnAcquireState; memberFuncMap_[static_cast(IFormHost::Message::FORM_HOST_ON_SHARE_FORM_RESPONSE)] = &FormHostStub::HandleOnShareFormResponse; + memberFuncMap_[static_cast(IFormHost::Message::FORM_HOST_ON_SIZE_CHANGED)] = + &FormHostStub::HandleOnSizeChanged; } FormHostStub::~FormHostStub() @@ -161,5 +163,17 @@ int32_t FormHostStub::HandleOnShareFormResponse(MessageParcel &data, MessageParc reply.WriteInt32(ERR_OK); return ERR_OK; } + +ErrCode FormHostStub::HandleOnSizeChanged(MessageParcel &data, MessageParcel &reply) +{ + std::unique_ptr formInfo(data.ReadParcelable()); + if (!formInfo) { + HILOG_ERROR("failed to ReadParcelable"); + return ERR_APPEXECFWK_PARCEL_ERROR; + } + OnSizeChanged(*formInfo); + reply.WriteInt32(ERR_OK); + return ERR_OK; +} } // namespace AppExecFwk } // namespace OHOS \ No newline at end of file diff --git a/interfaces/inner_api/src/form_js_info.cpp b/interfaces/inner_api/src/form_js_info.cpp index 53f76244bd0e85c3a7259141f8189a5a41829b37..46e9337d3e6da6fb62c08fd7a347190bfe66ea62 100644 --- a/interfaces/inner_api/src/form_js_info.cpp +++ b/interfaces/inner_api/src/form_js_info.cpp @@ -25,6 +25,7 @@ bool FormJsInfo::ReadFromParcel(Parcel &parcel) formName = Str16ToStr8(parcel.ReadString16()); bundleName = Str16ToStr8(parcel.ReadString16()); abilityName = Str16ToStr8(parcel.ReadString16()); + specification = parcel.ReadInt32(); formTempFlag = parcel.ReadBool(); jsFormCodePath = Str16ToStr8(parcel.ReadString16()); @@ -75,6 +76,10 @@ bool FormJsInfo::Marshalling(Parcel &parcel) const if (!parcel.WriteString16(Str8ToStr16(abilityName))) { return false; } + // write specification + if (!parcel.WriteInt32(specification)) { + return false; + } // write tempFlag if (!parcel.WriteBool(formTempFlag)) { diff --git a/interfaces/inner_api/src/form_mgr_proxy.cpp b/interfaces/inner_api/src/form_mgr_proxy.cpp index 651178c8af97a54c68bfb7dc211d23722308b6be..070f487e1bde10987080cb3c2775be7e13c96845 100644 --- a/interfaces/inner_api/src/form_mgr_proxy.cpp +++ b/interfaces/inner_api/src/form_mgr_proxy.cpp @@ -1133,6 +1133,41 @@ int32_t FormMgrProxy::GetFormsInfo(const FormInfoFilter &filter, std::vector &callerToken) +{ + MessageParcel data; + if (!WriteInterfaceToken(data)) { + HILOG_ERROR("failed to write interface token"); + return ERR_APPEXECFWK_PARCEL_ERROR; + } + if (!data.WriteInt64(formId)) { + HILOG_ERROR("failed to write formId"); + return ERR_APPEXECFWK_PARCEL_ERROR; + } + if (!data.WriteRemoteObject(callerToken)) { + HILOG_ERROR("failed to write callerToken"); + return ERR_APPEXECFWK_PARCEL_ERROR; + } + if (!data.WriteInt32(dimensionNum)) { + HILOG_ERROR("failed to write dimensionNum"); + return ERR_APPEXECFWK_PARCEL_ERROR; + } + + MessageParcel reply; + MessageOption option; + ErrCode error = Remote()->SendRequest( + static_cast(IFormMgr::Message::FORM_MGR_NOTIFY_FORM_SIZE_CHANGED), + data, + reply, + option); + if (error != ERR_OK) { + HILOG_ERROR("failed to SendRequest: %{public}d", error); + return ERR_APPEXECFWK_FORM_SEND_FMS_MSG; + } + return reply.ReadInt32(); +} + bool FormMgrProxy::IsRequestPublishFormSupported() { HILOG_INFO("%{public}s start.", __func__); diff --git a/interfaces/inner_api/src/form_mgr_stub.cpp b/interfaces/inner_api/src/form_mgr_stub.cpp index 3e52172abfa7f1b42d3381fbd7ade860fc1582b9..4b1b9509a954a088ead2da6bc43d276285f3e336 100644 --- a/interfaces/inner_api/src/form_mgr_stub.cpp +++ b/interfaces/inner_api/src/form_mgr_stub.cpp @@ -112,6 +112,8 @@ FormMgrStub::FormMgrStub() &FormMgrStub::HandleIsRequestPublishFormSupported; memberFuncMap_[static_cast(IFormMgr::Message::FORM_MGR_START_ABILITY)] = &FormMgrStub::HandleStartAbility; + memberFuncMap_[static_cast(IFormMgr::Message::FORM_MGR_NOTIFY_FORM_SIZE_CHANGED)] = + &FormMgrStub::HandleNotifyFormSizeChanged; } FormMgrStub::~FormMgrStub() @@ -903,6 +905,25 @@ int32_t FormMgrStub::HandleStartAbility(MessageParcel &data, MessageParcel &repl return result; } +ErrCode FormMgrStub::HandleNotifyFormSizeChanged(MessageParcel &data, MessageParcel &reply) +{ + int64_t formId = data.ReadInt64(); + sptr client = data.ReadRemoteObject(); + if (client == nullptr) { + return ERR_APPEXECFWK_PARCEL_ERROR; + } + int32_t dimensionNum = data.ReadInt32(); + + ErrCode result = NotifyFormSizeChanged(formId, dimensionNum, client); + + reply.WriteInt32(result); + if (!reply.WriteInt32(result)) { + HILOG_ERROR("failed to write result"); + return ERR_APPEXECFWK_PARCEL_ERROR; + } + return result; +} + /** * @brief Write a parcelabe vector objects to the proxy node. * @param parcelableVector Indicates the objects to be write. diff --git a/interfaces/inner_api/src/form_provider_proxy.cpp b/interfaces/inner_api/src/form_provider_proxy.cpp index 909100cfa5ebc8defb0dff7ae85881db51b71f41..819d97ea354014381fbb98c606743fa1c4c0f7cd 100644 --- a/interfaces/inner_api/src/form_provider_proxy.cpp +++ b/interfaces/inner_api/src/form_provider_proxy.cpp @@ -391,6 +391,43 @@ int FormProviderProxy::AcquireState(const Want &wantArg, const std::string &prov return ERR_OK; } +ErrCode FormProviderProxy::NotifyFormSizeChanged(int64_t formId, const Want &want, + const sptr &callerToken) +{ + MessageParcel data; + + if (!WriteInterfaceToken(data)) { + HILOG_ERROR("failed to write interface token"); + return ERR_APPEXECFWK_PARCEL_ERROR; + } + + if (!data.WriteInt64(formId)) { + HILOG_ERROR("failed to write formId"); + return ERR_APPEXECFWK_PARCEL_ERROR; + } + if (!data.WriteParcelable(&want)) { + HILOG_ERROR("failed to write want"); + return ERR_APPEXECFWK_PARCEL_ERROR; + } + if (!data.WriteRemoteObject(callerToken)) { + HILOG_ERROR("failed to write callerToken"); + return ERR_APPEXECFWK_PARCEL_ERROR; + } + + MessageParcel reply; + MessageOption option; + ErrCode error = Remote()->SendRequest( + static_cast(IFormProvider::Message::FORM_PROVIDER_NOTIFY_FORM_SIZE_CHANGE), + data, + reply, + option); + if (error != ERR_OK) { + HILOG_ERROR("failed to SendRequest: %{public}d", error); + return error; + } + return ERR_OK; +} + template int FormProviderProxy::GetParcelableInfos(MessageParcel &reply, std::vector &parcelableInfos) { diff --git a/interfaces/inner_api/src/form_provider_stub.cpp b/interfaces/inner_api/src/form_provider_stub.cpp index 9c625b78edf0a23920fc2fa310452c702201f2c3..786ed5aad67474b116185d13b38a1d94e6389019 100644 --- a/interfaces/inner_api/src/form_provider_stub.cpp +++ b/interfaces/inner_api/src/form_provider_stub.cpp @@ -44,6 +44,8 @@ FormProviderStub::FormProviderStub() &FormProviderStub::HandleAcquireState; memberFuncMap_[static_cast(IFormProvider::Message::FORM_ACQUIRE_PROVIDER_SHARE_FOMR_INFO)] = &FormProviderStub::HandleAcquireShareFormData; + memberFuncMap_[static_cast(IFormProvider::Message::FORM_PROVIDER_NOTIFY_FORM_SIZE_CHANGE)] = + &FormProviderStub::HandleNotifyFormSizeChaned; } FormProviderStub::~FormProviderStub() @@ -316,5 +318,26 @@ int32_t FormProviderStub::HandleAcquireShareFormData(MessageParcel &data, Messag return ERR_OK; } + +ErrCode FormProviderStub::HandleNotifyFormSizeChaned(MessageParcel &data, MessageParcel &reply) +{ + int64_t formId = data.ReadInt64(); + + std::unique_ptr want(data.ReadParcelable()); + if (!want) { + HILOG_ERROR("ReadParcelable failed"); + return ERR_APPEXECFWK_PARCEL_ERROR; + } + + sptr client = data.ReadRemoteObject(); + if (client == nullptr) { + HILOG_ERROR("failed to get remote object."); + return ERR_APPEXECFWK_PARCEL_ERROR; + } + + ErrCode result = NotifyFormSizeChanged(formId, *want, client); + reply.WriteInt32(result); + return result; +} } // namespace AppExecFwk } // namespace OHOS \ No newline at end of file diff --git a/interfaces/kits/native/include/form_host_client.h b/interfaces/kits/native/include/form_host_client.h index 403b5a2fcc1df64e543f81ead23cbab096acb2eb..3f2a25902cf88d235bd2c0031f6d07330c2ad4cc 100644 --- a/interfaces/kits/native/include/form_host_client.h +++ b/interfaces/kits/native/include/form_host_client.h @@ -139,6 +139,14 @@ public: * @param requestCode The request code of this share form. */ void RemoveShareFormCallback(int64_t requestCode); + + /** + * @brief Request to give back a form after form size changed. + * @param formJsInfo Form js info. + * @return none. + */ + void OnSizeChanged(const FormJsInfo &formJsInfo); + private: static std::mutex instanceMutex_; static sptr instance_; diff --git a/interfaces/kits/native/include/form_mgr.h b/interfaces/kits/native/include/form_mgr.h index 93766d4052548ce03d2ab448f94d0886a0419bce..413599db1d76f363a3749d61674dcee85d0dd5d0 100644 --- a/interfaces/kits/native/include/form_mgr.h +++ b/interfaces/kits/native/include/form_mgr.h @@ -392,6 +392,16 @@ public: */ bool CheckFMSReady(); + /** + * @brief notify form to size changed with formId and newDimension, + * send formId and new Dimension to form manager service. + * @param formId The Id of the forms to delete. + * @param dimensionId the newDimension of the form to reSize + * @param callerToken Caller ability token. + * @return Returns ERR_OK on success, others on failure. + */ + ErrCode NotifyFormSizeChanged(int64_t formId, int32_t dimensionId, const sptr &callerToken); + private: /** * @brief Connect form manager service. diff --git a/interfaces/kits/native/src/form_host_client.cpp b/interfaces/kits/native/src/form_host_client.cpp index 553bfacb255a4eaa3d843c85c3d1e7a072560c85..057c34d5170aabb7b13b2be4f90c4d1a0f04b9f0 100644 --- a/interfaces/kits/native/src/form_host_client.cpp +++ b/interfaces/kits/native/src/form_host_client.cpp @@ -317,5 +317,28 @@ void FormHostClient::RemoveShareFormCallback(int64_t requestCode) } HILOG_INFO("%{public}s end.", __func__); } + +void FormHostClient::OnSizeChanged(const FormJsInfo &formJsInfo) +{ + HILOG_DEBUG("OnSizeChanged called."); + HILOG_INFO("Imamge number is %{public}zu.", formJsInfo.imageDataMap.size()); + int64_t formId = formJsInfo.formId; + if (formId < 0) { + HILOG_ERROR("the passed form id can't be negative."); + return; + } + std::lock_guard lock(callbackMutex_); + auto iter = formCallbackMap_.find(formId); + if (iter == formCallbackMap_.end()) { + HILOG_ERROR("not find formId:%{public}s.", std::to_string(formId).c_str()); + return; + } + for (const auto& callback : iter->second) { + HILOG_INFO("formId: %{public}" PRId64 ", jspath: %{public}s, data: %{public}s", + formId, formJsInfo.jsFormCodePath.c_str(), formJsInfo.formData.c_str()); + if (callback != nullptr) + callback->ProcessFormUpdate(formJsInfo); + } +} } // namespace AppExecFwk } // namespace OHOS diff --git a/interfaces/kits/native/src/form_mgr.cpp b/interfaces/kits/native/src/form_mgr.cpp index c8640b3aee79d83d78cdcf93b5374dc73c8132f6..cd56bc7e12cd1c72501380fbdd6de9b9bcd44c3b 100644 --- a/interfaces/kits/native/src/form_mgr.cpp +++ b/interfaces/kits/native/src/form_mgr.cpp @@ -981,5 +981,42 @@ bool FormMgr::CheckFMSReady() return true; } + +ErrCode FormMgr::NotifyFormSizeChanged(int64_t formId, int32_t dimensionId, + const sptr &callerToken) +{ + HILOG_DEBUG("NotifyFormSizeChanged called."); + // check fms recover status + if (FormMgr::GetRecoverStatus() == Constants::IN_RECOVERING) { + HILOG_ERROR("form is in recover status, can't do action on form."); + return ERR_APPEXECFWK_FORM_SERVER_STATUS_ERR; + } + + // check formId + if (formId <= 0) { + HILOG_ERROR("the passed in formId can't be negative or zero."); + return ERR_APPEXECFWK_FORM_INVALID_FORM_ID; + } + + // check new Dimension + bool dimensionSign = false; + for (std::map::const_iterator it = Constants::DIMENSION_MAP.begin(); + it != Constants::DIMENSION_MAP.end(); it++) { + if (it->first == dimensionId) { + dimensionSign = true; + } + } + if (!dimensionSign) { + HILOG_ERROR("the passed new dimension is invalid."); + return ERR_APPEXECFWK_FORM_INVALID_PARAM; + } + + ErrCode errCode = Connect(); + if (errCode != ERR_OK) { + HILOG_ERROR("failed errCode:%{public}d.", errCode); + return errCode; + } + return remoteProxy_->NotifyFormSizeChanged(formId, dimensionId, callerToken); +} } // namespace AppExecFwk } // namespace OHOS diff --git a/services/include/form_data_mgr.h b/services/include/form_data_mgr.h index d2b0503b1f9c9cc9ea09f78b8e7246ea0233ed6f..4d3a77e7703285cedca6f8dc70f81dea97a08946 100644 --- a/services/include/form_data_mgr.h +++ b/services/include/form_data_mgr.h @@ -441,6 +441,14 @@ public: */ ErrCode SetRecordVisible(int64_t matchedFormId, bool isVisible); + /** + * @brief set form specification. + * @param formId form id. + * @param dspecification the specification + * @return Returns true if this function is successfully called; returns false otherwise. + */ + ErrCode SetRecordSpecification(int64_t formId, int32_t specification); + /** * @brief add request publish form info. * @param formId The form id of the form to publish. diff --git a/services/include/form_host_callback.h b/services/include/form_host_callback.h index 7e752632a52cdde8bbddd78b4d2f71eb1f7a7222..9738fb0569182a8e94b2b0966c424e026cb6f69a 100644 --- a/services/include/form_host_callback.h +++ b/services/include/form_host_callback.h @@ -51,6 +51,15 @@ public: * @return Returns ERR_OK on success, others on failure. */ void OnUpdate(const int64_t formId, const FormRecord &record, const sptr &callerToken); + + /** + * @brief Request to give back a Form after size changed. + * @param formId The Id of the form whose size is changed. + * @param record Form info. + * @param callerToken Caller ability token. + * @return Returns ERR_OK on success, others on failure. + */ + void OnSizeChanged(int64_t formId, const FormRecord &record, const sptr &callerToken); /** * @brief Form provider is uninstalled. diff --git a/services/include/form_host_record.h b/services/include/form_host_record.h index a2ade487a3408f97dfa9fdeadf8efb8d09232362..4e68328a10faec04e2ac93572d325d4332d798c9 100644 --- a/services/include/form_host_record.h +++ b/services/include/form_host_record.h @@ -114,6 +114,14 @@ public: * @param record Form record. */ void OnUpdate(int64_t id, const FormRecord &record); + + /** + * @brief Send form data after size changed to form host. + * @param formId The Id of the form. + * @param record Form record. + */ + void OnSizeChanged(int64_t formId, const FormRecord &record); + /** * Send form uninstall message to form host. * diff --git a/services/include/form_mgr_adapter.h b/services/include/form_mgr_adapter.h index 65dd7a2854215a65358788759e62a4f96a81bcb3..ac1ebf879fc158ad314a5a42ec8539f2ceb45a39 100644 --- a/services/include/form_mgr_adapter.h +++ b/services/include/form_mgr_adapter.h @@ -322,6 +322,24 @@ public: * @return Returns ERR_OK on success, others on failure. */ int UpdateRouterAction(const int64_t formId, std::string &action); + + /** + * @brief Get form info by form record. + * @param formRecord The form record. + * @param formInfos Return the form' information of the specify bundle name and module name. + * @return Returns ERR_OK on success, others on failure. + */ + ErrCode GetFormInfoByFormRecord(const FormRecord &formrecord, FormInfo &formInfo); + + /** + * @brief Notify the form to change size. + * @param formId Indicates the ID of the form. + * @param dimensionNum The new dimension num of the form. + * @param callerToken Host client. + * @return Returns ERR_OK on success, others on failure. + */ + ErrCode NotifyFormSizeChanged(int64_t formId, int32_t dimensionNum, + const sptr &callerToken); private: /** * @brief Get form configure info. diff --git a/services/include/form_mgr_service.h b/services/include/form_mgr_service.h index 10447821952b25c102446f9e9871a86ddeb74c52..7aee6b71763c0863718c44c4f4ba8bf66c7d6324 100644 --- a/services/include/form_mgr_service.h +++ b/services/include/form_mgr_service.h @@ -358,6 +358,16 @@ public: * @return Returns ERR_OK on success, others on failure. */ int Dump(int fd, const std::vector &args) override; + + /** + * @brief notify that the form size has been changed + * @param formId the formId + * @param dimensionNum the new dimensionNum of the form + * @param callerToken token of the ability that initially calls this function. + * @return Returns ERR_OK on success, others on failure. + */ + ErrCode NotifyFormSizeChanged(int64_t formId, int32_t dimensionNum, + const sptr &callerToken) override; private: enum class DumpKey { KEY_DUMP_HELP = 0, diff --git a/services/include/form_notify_size_changed_connection.h b/services/include/form_notify_size_changed_connection.h new file mode 100644 index 0000000000000000000000000000000000000000..4c9e26fac28eb2f9cef8056b810566e5514a021a --- /dev/null +++ b/services/include/form_notify_size_changed_connection.h @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2022 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. + */ + +#ifndef OHOS_FORM_FWK_FORM_NOTIFY_SIZE_CHANGE_CONNECTION_H +#define OHOS_FORM_FWK_FORM_NOTIFY_SIZE_CHANGE_CONNECTION_H + +#include "form_ability_connection.h" + +namespace OHOS { +namespace AppExecFwk { +/** + * @class FormNotifySizeChangedConnection + * Form notify to change size connection stub + */\ +class FormNotifySizeChangedConnection : public FormAbilityConnection { +public: + FormNotifySizeChangedConnection(int64_t formId, int32_t dimensionNum, + const std::string &bundleName, const std::string &abilityName); + virtual ~FormNotifySizeChangedConnection() = default; + + /** + * @brief OnAbilityConnectDone, AbilityMs notify caller ability the result of connect. + * @param element Service ability's ElementName. + * @param remoteObject The session proxy of service ability. + * @param resultCode return ERR_OK on success, others on failure. + */ + void OnAbilityConnectDone( + const AppExecFwk::ElementName &element, const sptr &remoteObject, int resultCode) override; + +private: + int64_t formId_ = -1; + int32_t dimensionNum_ = -1; + DISALLOW_COPY_AND_MOVE(FormNotifySizeChangedConnection); +}; +} // namespace AppExecFwk +} // namespace OHOS + +#endif // OHOS_FORM_FWK_FORM_NOTIFY_SIZE_CHANGE_CONNECTION_H diff --git a/services/include/form_provider_mgr.h b/services/include/form_provider_mgr.h index 61f1542de67c8b6f6c3988ae2ca7d9e784d7254b..dbfa7f085bb017e4b739607efe969d89259f6122 100644 --- a/services/include/form_provider_mgr.h +++ b/services/include/form_provider_mgr.h @@ -58,6 +58,14 @@ public: * @return Returns ERR_OK on success, others on failure. */ ErrCode UpdateForm(const int64_t formId, FormRecord &formRecord, const FormProviderData &formProviderData); + /** + * @brief handle for resize form event from provider. + * @param formId The id of the form. + * *@param want The want of the form to resize. + * @param providerFormInfo provider form info. + * @return Returns ERR_OK on success, others on failure. + */ + ErrCode ResizeForm(int64_t formId, const Want &want, const FormProviderInfo &formProviderInfo); /** * @brief Refresh form. * @param formId The form id. diff --git a/services/include/form_task_mgr.h b/services/include/form_task_mgr.h index 24994189a5d70f9da41581c63a35e7f4ee6b5a2d..55e64e68f0b1b9722793d5c086d004b8794ad07c 100644 --- a/services/include/form_task_mgr.h +++ b/services/include/form_task_mgr.h @@ -119,6 +119,15 @@ public: */ void PostUpdateTaskToHost(const int64_t formId, const FormRecord &record, const sptr &remoteObject); + /** + * @brief Post form data to form host(task) when change form size. + * @param formId The Id of the form. + * @param record form record. + * @param remoteObject Form provider proxy object. + */ + void PostSizeChangedTaskToHost(int64_t formId, const FormRecord &record, + const sptr &remoteObject); + /** * @brief Handel form host died(task). * @param remoteHost Form host proxy object. @@ -178,6 +187,16 @@ public: * @param result The error code of this share. */ void PostFormShareSendResponse(int64_t formShareRequestCode, int32_t result); + + /** + * @brief Post notify form size change to form provider(task). + * @param formId The form id. + * @param want The want of notifyFormSizeChanged. + * @param dimensionNum The dimension id of the new form. + * @param remoteObject Form provider proxy object. + */ + void PostNotifyFormSizeChanged(int64_t formId, int32_t dimensionNum, + const Want &want, const sptr &remoteObject); private: /** * @brief Acquire form data from form provider. @@ -249,6 +268,14 @@ private: */ void UpdateTaskToHost(const int64_t formId, const FormRecord &record, const sptr &remoteObject); + /** + * @brief Post form data to form host when change form size. + * @param formId The Id of the form. + * @param record form record. + * @param remoteObject Form provider proxy object. + */ + void SizeChangedTaskToHost(int64_t formId, const FormRecord &record, const sptr &remoteObject); + /** * @brief Handle form host died. * @param remoteHost Form host proxy object. @@ -297,7 +324,16 @@ private: */ void AcquireStateBack(AppExecFwk::FormState state, const AAFwk::Want &want, const sptr &remoteObject); - + + /** + * @brief Handle notify form size change to form provider. + * @param formId The form id. + * @param want The want of notifyFormSizeChanged. + * @param dimensionNum The dimension id of the new form. + * @param remoteObject Form provider proxy object. + */ + void NotifyProviderFormSizeChanged(int64_t formId, int32_t dimensionNum, + const Want &want, const sptr &remoteObject); /** * @brief Create form data for form host. * @param formId The Id of the form. diff --git a/services/src/form_data_mgr.cpp b/services/src/form_data_mgr.cpp index 9f847164f12a03f97dae531fe38e229d19f9ccd0..7fc008418a598f062c03ad12941108f1534dd7cc 100644 --- a/services/src/form_data_mgr.cpp +++ b/services/src/form_data_mgr.cpp @@ -1314,6 +1314,20 @@ ErrCode FormDataMgr::SetRecordVisible(int64_t matchedFormId, bool isVisible) return ERR_OK; } +ErrCode FormDataMgr::SetRecordSpecification(int64_t formId, int32_t specification) +{ + HILOG_DEBUG("set form specification"); + std::lock_guard lock(formRecordMutex_); + auto info = formRecords_.find(formId); + if (info == formRecords_.end()) { + HILOG_ERROR("form info not find"); + return ERR_APPEXECFWK_FORM_INVALID_FORM_ID; + } + info->second.specification = specification; + HILOG_DEBUG("set specification to %{public}d, formId: %{public}" PRId64 " ", specification, formId); + return ERR_OK; +} + /** * @brief delete forms by userId. * diff --git a/services/src/form_host_callback.cpp b/services/src/form_host_callback.cpp index 70a3c2cc6e1e9fc86c34196449932a558c8d797d..ec133d13c8edf3a11ac8434cc19c4e8c82d5fbc6 100644 --- a/services/src/form_host_callback.cpp +++ b/services/src/form_host_callback.cpp @@ -61,6 +61,26 @@ void FormHostCallback::OnUpdate(const int64_t formId, const FormRecord &record, FormTaskMgr::GetInstance().PostUpdateTaskToHost(formId, record, callerToken); } +void FormHostCallback::OnSizeChanged(int64_t formId, const FormRecord &record, + const sptr &callerToken) +{ + HILOG_DEBUG("OnSizeChanged start."); + + // check formId + if (formId < 0) { + HILOG_ERROR("OnSizeChanged invalid param, formId:%{public}" PRId64 ".", formId); + return; + } + + if (callerToken == nullptr) { + HILOG_ERROR("callerToken can not be NULL"); + return; + } + + // post updateTask to host + FormTaskMgr::GetInstance().PostSizeChangedTaskToHost(formId, record, callerToken); +} + /** * @brief Form provider is uninstalled * @param formIds The Id list of the forms. diff --git a/services/src/form_host_record.cpp b/services/src/form_host_record.cpp index 7b06ac66ad0c0e41db6c5bbf7b2a564ec8223ca7..49f9cd9be1393e4dd2af7efa471e7ed84f7f1b18 100644 --- a/services/src/form_host_record.cpp +++ b/services/src/form_host_record.cpp @@ -170,6 +170,16 @@ void FormHostRecord::OnUpdate(int64_t id, const FormRecord &record) formHostCallback_->OnUpdate(id, record, formHostClient_); } +void FormHostRecord::OnSizeChanged(int64_t formId, const FormRecord &record) +{ + HILOG_DEBUG("FormHostRecord OnSizeChanged"); + if (formHostCallback_ == nullptr) { + HILOG_ERROR("formHostCallback_ can not be NULL"); + return; + } + formHostCallback_->OnSizeChanged(formId, record, formHostClient_); +} + /** * @brief Send form uninstall message to form host. * @param formIds The id list of the form. diff --git a/services/src/form_mgr_adapter.cpp b/services/src/form_mgr_adapter.cpp index 278fc58034bea9f68454747f228d109fe8b0652f..355031549818bd7bec455dc2464056efe536a35f 100644 --- a/services/src/form_mgr_adapter.cpp +++ b/services/src/form_mgr_adapter.cpp @@ -24,6 +24,7 @@ #endif #include "form_acquire_connection.h" #include "form_acquire_state_connection.h" +#include "form_notify_size_changed_connection.h" #include "form_ams_helper.h" #include "form_bms_helper.h" #include "form_cache_mgr.h" @@ -2337,5 +2338,89 @@ bool FormMgrAdapter::IsRequestPublishFormSupported() } return true; } + +ErrCode FormMgrAdapter::GetFormInfoByFormRecord(const FormRecord &formRecord, FormInfo &formInfo) +{ + std::vector formInfos {}; + ErrCode errCode = FormInfoMgr::GetInstance().GetFormsInfoByModule(formRecord.bundleName, + formRecord.moduleName, formInfos); + if (errCode != ERR_OK) { + HILOG_ERROR("GetFormsInfoByModule, failed to get form config info."); + return ERR_APPEXECFWK_FORM_GET_INFO_FAILED; + } + + if (formRecord.formName.empty()) { + for (const auto &form : formInfos) { + if (form.defaultFlag) { + formInfo = form; + HILOG_DEBUG("GetFormInfo end."); + break; + } + } + } else { + for (const auto &form : formInfos) { + if (form.name == formRecord.formName) { + formInfo = form; + HILOG_DEBUG("GetFormInfo end."); + break; + } + } + } + + return ERR_OK; +} + +ErrCode FormMgrAdapter::NotifyFormSizeChanged(int64_t formId, int32_t dimensionNum, + const sptr &callerToken) +{ + HILOG_DEBUG("NotifyFormSizeChanged called."); + if (formId <= 0 || callerToken == nullptr) { + HILOG_ERROR("invalid param"); + return ERR_APPEXECFWK_FORM_INVALID_PARAM; + } + + FormRecord record; + FormDataMgr::GetInstance().GetFormRecord(formId, record); + + if (record.formUserUids.size() > 1) { + HILOG_ERROR("Failed to resize when there are more than one user."); + return ERR_APPEXECFWK_FORM_INVALID_PARAM; + } + + if (dimensionNum == record.specification) { + HILOG_ERROR("This form want to change to the same size."); + return ERR_APPEXECFWK_FORM_INVALID_PARAM; + } + + FormInfo formInfo; + ErrCode errCode = GetFormInfoByFormRecord(record, formInfo); + if (errCode != ERR_OK) + return errCode; + + bool isSupportFormDimension = false; + for (auto iter : formInfo.supportDimensions) { + if (dimensionNum == iter) { + isSupportFormDimension = true; + } + } + if (!isSupportFormDimension) { + HILOG_ERROR("This form soesn't support the new dimension."); + return ERR_APPEXECFWK_FORM_INVALID_PARAM; + } + + sptr formNotifySizeChangedConnection = + new FormNotifySizeChangedConnection(formId, dimensionNum, record.bundleName, record.abilityName); + + Want want; + want.AddFlags(Want::FLAG_ABILITY_FORM_ENABLED); + want.SetElementName(record.bundleName, record.abilityName); + ErrCode errorCode = FormAmsHelper::GetInstance().ConnectServiceAbility(want, formNotifySizeChangedConnection); + if (errorCode != ERR_OK) { + HILOG_ERROR("ConnectServiceAbility failed."); + return ERR_APPEXECFWK_FORM_BIND_PROVIDER_FAILED; + } + + return ERR_OK; +} } // namespace AppExecFwk } // namespace OHOS diff --git a/services/src/form_mgr_service.cpp b/services/src/form_mgr_service.cpp index 497ae9521a7c9e6098aa572f5fc712ed4d525cc0..e746d6c5e82cc607492dd1ec971f900bda7e451d 100644 --- a/services/src/form_mgr_service.cpp +++ b/services/src/form_mgr_service.cpp @@ -903,5 +903,19 @@ void FormMgrService::HiDumpFormInfoByFormId(const std::string &args, std::string } DumpFormInfoByFormId(formId, result); } + +ErrCode FormMgrService::NotifyFormSizeChanged(int64_t formId, int32_t dimensionNum, + const sptr &callerToken) +{ + HILOG_DEBUG("NotifyFormSizeChanged called."); + + ErrCode ret = CheckFormPermission(); + if (ret != ERR_OK) { + HILOG_ERROR("release form permission denied"); + return ret; + } + + return FormMgrAdapter::GetInstance().NotifyFormSizeChanged(formId, dimensionNum, callerToken); +} } // namespace AppExecFwk } // namespace OHOS diff --git a/services/src/form_notify_size_changed_connection.cpp b/services/src/form_notify_size_changed_connection.cpp new file mode 100644 index 0000000000000000000000000000000000000000..03e1eec26c8601d488a38223166cf582b9dc6836 --- /dev/null +++ b/services/src/form_notify_size_changed_connection.cpp @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2022 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. + */ + +#include "form_notify_size_changed_connection.h" + +#include + +#include "form_constants.h" +#include "form_supply_callback.h" +#include "form_task_mgr.h" +#include "hilog_wrapper.h" +#include "want.h" + +namespace OHOS { +namespace AppExecFwk { +FormNotifySizeChangedConnection::FormNotifySizeChangedConnection(int64_t formId, int32_t dimensionNum, + const std::string &bundleName, const std::string &abilityName) + : formId_(formId), dimensionNum_(dimensionNum) +{ + SetProviderKey(bundleName, abilityName); +} + +void FormNotifySizeChangedConnection::OnAbilityConnectDone( + const AppExecFwk::ElementName &element, const sptr &remoteObject, int resultCode) +{ + HILOG_DEBUG("OnAbilityConnectDone called."); + if (resultCode != ERR_OK) { + HILOG_ERROR("abilityName:%{public}s, formId:%{public}" PRId64 ", resultCode:%{public}d", + element.GetAbilityName().c_str(), formId_, resultCode); + return; + } + FormSupplyCallback::GetInstance()->AddConnection(this); + int32_t dimensionNum = dimensionNum_; + if (dimensionNum == -1) { + HILOG_ERROR("the dimension info is wrong"); + return; + } + Want newWant; + newWant.SetParam(Constants::FORM_CONNECT_ID, this->GetConnectId()); + FormTaskMgr::GetInstance().PostNotifyFormSizeChanged(formId_, dimensionNum, newWant, remoteObject); +} +} // namespace AppExecFwk +} // namespace OHOS \ No newline at end of file diff --git a/services/src/form_provider_mgr.cpp b/services/src/form_provider_mgr.cpp index e37c478f85323f95f2c9ea9f23596fadc98213cb..43544775734c4d0e29ecbe67335cd0c566f58b6a 100644 --- a/services/src/form_provider_mgr.cpp +++ b/services/src/form_provider_mgr.cpp @@ -95,6 +95,22 @@ ErrCode FormProviderMgr::AcquireForm(const int64_t formId, const FormProviderInf return ERR_OK; } +ErrCode FormProviderMgr::ResizeForm(int64_t formId, const Want &want, const FormProviderInfo &formProviderInfo) +{ + HILOG_INFO("ResizeForm called, formId:%{public}" PRId64 ".", formId); + + int32_t dimensionId = want.GetIntParam(Constants::PARAM_FORM_DIMENSION_KEY, 0); + if (dimensionId == 0) { + HILOG_ERROR("the dimensionId is wrong, formId:%{public}" PRId64 "", formId); + return ERR_APPEXECFWK_FORM_INVALID_PARAM; + } + + // update the specification of formRecord + FormDataMgr::GetInstance().SetRecordSpecification(formId, dimensionId); + + return AcquireForm(formId, formProviderInfo); +} + /** * @brief Refresh form. * diff --git a/services/src/form_supply_callback.cpp b/services/src/form_supply_callback.cpp index 13cfac71fc77ffd0ab05ee48b699e4b8d752f98a..39af0267714235e539b85774dd6540e071c16bc9 100644 --- a/services/src/form_supply_callback.cpp +++ b/services/src/form_supply_callback.cpp @@ -75,6 +75,8 @@ int FormSupplyCallback::OnAcquire(const FormProviderInfo &formProviderInfo, cons return FormProviderMgr::GetInstance().AcquireForm(formId, formProviderInfo); case Constants::ACQUIRE_TYPE_RECREATE_FORM: return FormProviderMgr::GetInstance().UpdateForm(formId, formProviderInfo); + case Constants::ACQUIRE_TYPE_RESIZE_FORM: + return FormProviderMgr::GetInstance().ResizeForm(formId, want, formProviderInfo); default: HILOG_WARN("%{public}s warning, onAcquired type: %{public}d", __func__, type); } diff --git a/services/src/form_task_mgr.cpp b/services/src/form_task_mgr.cpp index 7a7ce1ef8cdfb6b6e73f394f35183ab4442bc6b1..00679bb4fa49f414862cb610805060bddd1ddf6a 100644 --- a/services/src/form_task_mgr.cpp +++ b/services/src/form_task_mgr.cpp @@ -171,6 +171,23 @@ void FormTaskMgr::PostUpdateTaskToHost(const int64_t formId, const FormRecord &r eventHandler_->PostTask(updateTaskToHostFunc, FORM_TASK_DELAY_TIME); } +void FormTaskMgr::PostSizeChangedTaskToHost(int64_t formId, const FormRecord &record, + const sptr &remoteObject) +{ + HILOG_DEBUG("PostSizeChangedTaskToHost called."); + + if (eventHandler_ == nullptr) { + HILOG_ERROR("event handler invalidate."); + return; + } + + HILOG_DEBUG("%{public}s, post the task of sizeChangedTaskToHostFunc.", __func__); + auto sizeChangedTaskToHostFunc = [formId, record, remoteObject]() { + FormTaskMgr::GetInstance().SizeChangedTaskToHost(formId, record, remoteObject); + }; + eventHandler_->PostTask(sizeChangedTaskToHostFunc, FORM_TASK_DELAY_TIME); +} + /** * @brief Acquire form data from form provider. * @param formId The Id of the form. @@ -328,6 +345,19 @@ void FormTaskMgr::PostFormShareSendResponse(int64_t formShareRequestCode, int32_ HILOG_INFO("%{public}s end", __func__); } +void FormTaskMgr::PostNotifyFormSizeChanged(int64_t formId, int32_t dimensionNum, + const Want &want, const sptr &remoteObject) +{ + if (eventHandler_ == nullptr) { + HILOG_ERROR("event handler invalidate"); + return; + } + auto notifyFormSizeChangedFunc = [formId, dimensionNum, want, remoteObject]() { + FormTaskMgr::GetInstance().NotifyProviderFormSizeChanged(formId, dimensionNum, want, remoteObject); + }; + eventHandler_->PostTask(notifyFormSizeChangedFunc, FORM_TASK_DELAY_TIME); +} + void FormTaskMgr::AcquireProviderFormInfo(const int64_t formId, const Want &want, const sptr &remoteObject) { @@ -482,6 +512,23 @@ void FormTaskMgr::UpdateTaskToHost(const int64_t formId, const FormRecord &recor HILOG_INFO("%{public}s end.", __func__); } +void FormTaskMgr::SizeChangedTaskToHost(int64_t formId, const FormRecord &record, + const sptr &remoteObject) +{ + HILOG_DEBUG("SizeChangedTaskToHost start."); + + sptr remoteFormHost = iface_cast(remoteObject); + if (remoteFormHost == nullptr) { + HILOG_ERROR("Failed to get form host proxy."); + return; + } + + HILOG_DEBUG("FormTaskMgr remoteFormHost OnUpdate."); + remoteFormHost->OnSizeChanged(CreateFormJsInfo(formId, record)); + + HILOG_DEBUG("SizeChangedTaskToHost end."); +} + /** * @brief Handle form host died. * @param remoteHost Form host proxy object. @@ -615,6 +662,29 @@ void FormTaskMgr::AcquireStateBack(AppExecFwk::FormState state, const AAFwk::Wan HILOG_INFO("%{public}s end", __func__); } +void FormTaskMgr::NotifyProviderFormSizeChanged(int64_t formId, int32_t dimensionNum, + const Want &want, const sptr &remoteObject) +{ + HILOG_DEBUG("NotifyProviderFormSizeChange called."); + + long connectId = want.GetLongParam(Constants::FORM_CONNECT_ID, 0); + sptr formProviderProxy = iface_cast(remoteObject); + if (formProviderProxy == nullptr) { + FormSupplyCallback::GetInstance()->RemoveConnection(connectId); + HILOG_ERROR("failed to get formProviderProxy"); + return; + } + + Want newWant(want); + newWant.SetParam(Constants::PARAM_FORM_DIMENSION_KEY, dimensionNum); + + int error = formProviderProxy->NotifyFormSizeChanged(formId, newWant, FormSupplyCallback::GetInstance()); + if (error != ERR_OK) { + FormSupplyCallback::GetInstance()->RemoveConnection(connectId); + HILOG_ERROR("Failed to notify form update."); + } +} + /** * @brief Create form data for form host. * @param formId The Id of the form. @@ -629,6 +699,7 @@ FormJsInfo FormTaskMgr::CreateFormJsInfo(const int64_t formId, const FormRecord form.bundleName = record.bundleName; form.abilityName = record.abilityName; form.formName = record.formName; + form.specification = record.specification; form.formTempFlag = record.formTempFlag; form.jsFormCodePath = record.jsFormCodePath; form.formData = record.formProviderInfo.GetFormDataString(); diff --git a/test/mock/include/mock_form_host_client.h b/test/mock/include/mock_form_host_client.h index 45be8b73d262f9b975d42a1c078ebaa0ab37c033..094d894d0286479a9ee5c47edc3da3ca2eee74bb 100644 --- a/test/mock/include/mock_form_host_client.h +++ b/test/mock/include/mock_form_host_client.h @@ -88,6 +88,12 @@ public: * @param result Share form result. */ virtual void OnShareFormResponse(int64_t requestCode, int32_t result) override; + + /** + * @brief Request to give back a Form after size changed. + * @param formInfo Form info. + */ + virtual void OnSizeChanged(const FormJsInfo &formInfo) override; private: Semaphore sem_; DISALLOW_COPY_AND_MOVE(MockFormHostClient); diff --git a/test/mock/include/mock_form_mgr_proxy.h b/test/mock/include/mock_form_mgr_proxy.h index 34af89aab2fc277a8ff1ae3a7e9f46de12b4d5a8..4a96bc7fc011aabb0f2912e906932f51039ac036 100644 --- a/test/mock/include/mock_form_mgr_proxy.h +++ b/test/mock/include/mock_form_mgr_proxy.h @@ -27,6 +27,8 @@ public: MOCK_METHOD2(GetFormsInfo, int(const FormInfoFilter &filter, std::vector &formInfos)); MOCK_METHOD0(IsRequestPublishFormSupported, bool()); MOCK_METHOD2(StartAbility, int32_t(const Want &want, const sptr &callerToken)); + MOCK_METHOD3(NotifyFormSizeChanged, int(int64_t formId, int32_t dimensionNum, + const sptr &callerToken)); }; } } diff --git a/test/mock/include/mock_form_mgr_service.h b/test/mock/include/mock_form_mgr_service.h index a9be8794b642b9c7a1f92768d08da407afd75a3b..f2afc76cff6175908986ebdf31e0464ff4a6b880 100644 --- a/test/mock/include/mock_form_mgr_service.h +++ b/test/mock/include/mock_form_mgr_service.h @@ -68,6 +68,8 @@ public: MOCK_METHOD2(UpdateRouterAction, int(const int64_t formId, std::string &action)); MOCK_METHOD4(ShareForm, int32_t(int64_t, const std::string&, const sptr&, int64_t)); MOCK_METHOD1(RecvFormShareInfoFromRemote, int32_t(const FormShareInfo&)); + MOCK_METHOD3(NotifyFormSizeChanged, int32_t(int64_t formId, int32_t dimensionNum, + const sptr &callerToken)); }; } } diff --git a/test/mock/include/mock_form_provider_client.h b/test/mock/include/mock_form_provider_client.h index bd5cada03e8395e3907d117d94da81b670d08624..5dc933e3c08376817ef3c8d079029a7bd91bb6cc 100644 --- a/test/mock/include/mock_form_provider_client.h +++ b/test/mock/include/mock_form_provider_client.h @@ -107,6 +107,15 @@ private: virtual int FireFormEvent(const int64_t formId, const std::string &message, const Want &want, const sptr &callerToken) override; + /** + * @brief Notify provider when the form want to change the size. + * @param formId The Id of the form to update. + * @param want the want of the request containing the new formDimensionNum. + * @param callerToken Caller ability token. + * @return Returns ERR_OK on success, others on failure. + */ + virtual int NotifyFormSizeChanged(int64_t formId, const Want &want, + const sptr &callerToken) override; /** * @brief Acquire form state to form provider. * @param wantArg The want of onAcquireFormState. diff --git a/test/mock/src/mock_form_host_client.cpp b/test/mock/src/mock_form_host_client.cpp index 7033aa2497a65dd571a926cc733db79ae33972f0..9240e5da83a89d9937765d9ca2a6b021c8195fa9 100644 --- a/test/mock/src/mock_form_host_client.cpp +++ b/test/mock/src/mock_form_host_client.cpp @@ -71,5 +71,11 @@ void MockFormHostClient::OnShareFormResponse(int64_t requestCode, int32_t result HILOG_DEBUG("MockFormHostClient OnShareFormResponse"); PostVoid(); } + +void MockFormHostClient::OnSizeChanged(const FormJsInfo &formInfo) +{ + HILOG_DEBUG("MockFormHostClient OnSizeChanged"); + PostVoid(); +} } // namespace AppExecFwk } // namespace OHOS diff --git a/test/mock/src/mock_form_provider_client.cpp b/test/mock/src/mock_form_provider_client.cpp index 97e7462bb26778eb9c13d67c2ee5f58e2c43ac0f..413a387e621eeedf71cabf064e9f0fca21afd084 100644 --- a/test/mock/src/mock_form_provider_client.cpp +++ b/test/mock/src/mock_form_provider_client.cpp @@ -139,6 +139,21 @@ int MockFormProviderClient::FireFormEvent(const int64_t formId, const std::strin return ERR_OK; } +/** + * @brief Notify provider when the form want to change the size. + * @param formId The Id of the form to update. + * @param want the want of the request containing the new formDimensionNum. + * @param callerToken Caller ability token. + * @return Returns ERR_OK on success, others on failure. + */ +int MockFormProviderClient::NotifyFormSizeChanged(const int64_t formId, const Want &want, + const sptr &callerToken) +{ + HILOG_DEBUG("notify form size changed"); + return ERR_OK; +} + + /** * @brief Acquire form state to form provider. * @param wantArg The want of onAcquireFormState. diff --git a/test/unittest/fms_form_mgr_release_form_test/fms_form_mgr_release_form_test.cpp b/test/unittest/fms_form_mgr_release_form_test/fms_form_mgr_release_form_test.cpp index 1d35c44c2d987ef5227245cb01b7bd0f16ba251b..0ea3bd705e3775cb26f98c824bb0b0eef8e99e83 100644 --- a/test/unittest/fms_form_mgr_release_form_test/fms_form_mgr_release_form_test.cpp +++ b/test/unittest/fms_form_mgr_release_form_test/fms_form_mgr_release_form_test.cpp @@ -1,3 +1,4 @@ + /* * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test/unittest/fms_form_share_mgr_test/fms_form_share_mgr_test.cpp b/test/unittest/fms_form_share_mgr_test/fms_form_share_mgr_test.cpp index bc377cf80ca5565df0a17c9d0d914a8a9db9aa46..20d90276b6414cfa18cf8d2048b092aca0031e50 100644 --- a/test/unittest/fms_form_share_mgr_test/fms_form_share_mgr_test.cpp +++ b/test/unittest/fms_form_share_mgr_test/fms_form_share_mgr_test.cpp @@ -105,6 +105,7 @@ public: MOCK_METHOD1(OnUninstall, void(const std::vector &formIds)); MOCK_METHOD2(OnAcquireState, void(AppExecFwk::FormState state, const AAFwk::Want &want)); MOCK_METHOD2(OnShareFormResponse, void(const int64_t requestCode, const int32_t result)); + MOCK_METHOD1(OnSizeChanged, void(const FormJsInfo &formInfo)); }; static sptr bundleMgr_ = nullptr; diff --git a/test/unittest/form_mgr_proxy_test/form_mgr_proxy_test.cpp b/test/unittest/form_mgr_proxy_test/form_mgr_proxy_test.cpp index 7715cc3d6b0b95e185cd3fb7665989338b16211c..685d154545c74626380ca7bc90c3bd98a1b7c6fb 100644 --- a/test/unittest/form_mgr_proxy_test/form_mgr_proxy_test.cpp +++ b/test/unittest/form_mgr_proxy_test/form_mgr_proxy_test.cpp @@ -169,4 +169,27 @@ HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0005, TestSize.Level1) { EXPECT_EQ(result, ERR_APPEXECFWK_PARCEL_ERROR); GTEST_LOG_(INFO) << "FormMgrProxyTest_0005 test ends"; } + +/** + * @tc.name: FormMgrProxyTest_0006 + * @tc.desc: Verify NotifyFormSizeChanged + * @tc.type: FUNC + * @tc.require: #I5MLR5 + */ +HWTEST_F(FormMgrProxyTest, FormMgrProxyTest_0006, TestSize.Level1) { + GTEST_LOG_(INFO) << "FormMgrProxyTest_0006 starts"; + // initialize input parameters. + int64_t formId = 1; + int32_t dimensionNum = 1; + sptr token = new (std::nothrow) MockFormToken(); + + EXPECT_CALL(*mockFormMgrService, NotifyFormSizeChanged(_, _, _)) + .Times(1) + .WillOnce(Return(0)); + // test. + bool result = formMgrProxy->NotifyFormSizeChanged(formId, dimensionNum, token); + // expect result. + EXPECT_EQ(result, 0); + GTEST_LOG_(INFO) << "FormMgrProxyTest_0006 test ends"; +} } \ No newline at end of file diff --git a/test/unittest/form_mgr_stub_test/form_mgr_stub_test.cpp b/test/unittest/form_mgr_stub_test/form_mgr_stub_test.cpp index 72eb4d04681a17266d219e545d2a52c210334ccd..982596b3949416c500a6aa72e74cc28a3bbef433 100644 --- a/test/unittest/form_mgr_stub_test/form_mgr_stub_test.cpp +++ b/test/unittest/form_mgr_stub_test/form_mgr_stub_test.cpp @@ -193,4 +193,40 @@ HWTEST_F(FormMgrStubTest, FormMgrStubTest_0004, TestSize.Level1) { EXPECT_EQ(result, 0); GTEST_LOG_(INFO) << "FormMgrStubTest_0004 ends"; } + +/** + * @tc.name: FormMgrStubTest_0005 + * @tc.desc: Verify HandleNotifyFormSizeChanged + * @tc.type: FUNC + * @tc.require: #I5MLR5 + */ +HWTEST_F(FormMgrStubTest, FormMgrStubTest_0005, TestSize.Level1) { + GTEST_LOG_(INFO) << "FormMgrStubTest_0005 starts"; + // initialize input parameters. + MessageParcel data; + MessageParcel reply; + + int64_t formId = 1; + sptr token = new (std::nothrow) MockFormToken(); + int32_t dimensionNum = 1; + + // write in formId + data.WriteInt64(formId); + // write in token + data.WriteRemoteObject(token); + // write in dimensionNum + data.WriteInt32(dimensionNum); + EXPECT_CALL(*mockFormMgrService, NotifyFormSizeChanged(_, _, _)) + .Times(1) + .WillOnce(Return(0)); + // test. + int32_t errCode = mockFormMgrService->HandleNotifyFormSizeChanged(data, reply); + // check errorcode + EXPECT_EQ(ERR_OK, errCode); + // check resulting infos. + int32_t result; + reply.ReadInt32(result); + EXPECT_EQ(result, 0); + GTEST_LOG_(INFO) << "FormMgrStubTest_0005 ends"; +} } \ No newline at end of file diff --git a/test/unittest/form_mgr_test/form_mgr_test.cpp b/test/unittest/form_mgr_test/form_mgr_test.cpp index 320b9d17a80fc3d644e885d0fb606a5478728f93..275adb844b636307c5621dcb3cd6b6e423d70753 100644 --- a/test/unittest/form_mgr_test/form_mgr_test.cpp +++ b/test/unittest/form_mgr_test/form_mgr_test.cpp @@ -158,4 +158,70 @@ HWTEST_F(FormMgrTest, FormMgrTest_0004, TestSize.Level1) { EXPECT_EQ(result, 0); GTEST_LOG_(INFO) << "FormMgrTest_0004 test ends"; } + +/** + * @tc.name: FormMgrTest_0005 + * @tc.desc: Verify NotifyFormSizeChanged while the dimensionId and formId are valid + * @tc.type: FUNC + * @tc.require: #I5MLR5 + */ +HWTEST_F(FormMgrTest, FormMgrTest_0005, TestSize.Level1) { + GTEST_LOG_(INFO) << "FormMgrTest_0005 starts"; + // initialize input parameters. + int64_t formId = 1; + int32_t dimensionId = 1; + sptr token = new (std::nothrow) MockFormToken(); + + EXPECT_CALL(*mockProxy, NotifyFormSizeChanged(_, _, _)) + .Times(1) + .WillOnce(Return(0)); + + int32_t result = FormMgr::GetInstance().NotifyFormSizeChanged(formId, dimensionId, token); + EXPECT_EQ(result, 0); + GTEST_LOG_(INFO) << "FormMgrTest_0005 test ends"; +} + +/** + * @tc.name: FormMgrTest_0006 + * @tc.desc: Verify NotifyFormSizeChanged while the formId is invalid + * @tc.type: FUNC + * @tc.require: #I5MLR5 + */ +HWTEST_F(FormMgrTest, FormMgrTest_0006, TestSize.Level1) { + GTEST_LOG_(INFO) << "FormMgrTest_0006 starts"; + // initialize input parameters. + int64_t formId = 0; + int32_t dimensionId = 1; + sptr token = new (std::nothrow) MockFormToken(); + + EXPECT_CALL(*mockProxy, NotifyFormSizeChanged(_, _, _)) + .Times(1) + .WillOnce(Return(0)); + + int32_t result = FormMgr::GetInstance().NotifyFormSizeChanged(formId, dimensionId, token); + EXPECT_EQ(result, 2293768); + GTEST_LOG_(INFO) << "FormMgrTest_0006 test ends"; +} + +/** + * @tc.name: FormMgrTest_0007 + * @tc.desc: Verify NotifyFormSizeChanged while the dimensionId is invalid + * @tc.type: FUNC + * @tc.require: #I5MLR5 + */ +HWTEST_F(FormMgrTest, FormMgrTest_0007, TestSize.Level1) { + GTEST_LOG_(INFO) << "FormMgrTest_0007 starts"; + // initialize input parameters. + int64_t formId = 1; + int32_t dimensionId = 0; + sptr token = new (std::nothrow) MockFormToken(); + + EXPECT_CALL(*mockProxy, NotifyFormSizeChanged(_, _, _)) + .Times(1) + .WillOnce(Return(0)); + + int32_t result = FormMgr::GetInstance().NotifyFormSizeChanged(formId, dimensionId, token); + EXPECT_EQ(result, 2293767); + GTEST_LOG_(INFO) << "FormMgrTest_0007 test ends"; +} } // namespace \ No newline at end of file