diff --git a/frameworks/js/napi/form_host/js_form_host.cpp b/frameworks/js/napi/form_host/js_form_host.cpp index f2106ab62cb0971fea2ba00d8322eb2272010154..5a04afb16dcd0206c4deff8e1cae8e677146d183 100644 --- a/frameworks/js/napi/form_host/js_form_host.cpp +++ b/frameworks/js/napi/form_host/js_form_host.cpp @@ -18,6 +18,7 @@ #include "fms_log_wrapper.h" #include "form_info.h" +#include "form_info_filter.h" #include "form_instance.h" #include "form_instances_filter.h" #include "form_callback_interface.h" @@ -1253,15 +1254,62 @@ private: return result; } + napi_value GetFormsInfoByFilter(napi_env env, size_t argc, napi_value* argv) + { + HILOG_DEBUG("%{public}s is called", __FUNCTION__); + if (argc != ARGS_ONE) { + HILOG_ERROR("wrong number of arguments."); + NapiFormUtil::ThrowParamNumError(env, std::to_string(argc), "1"); + return CreateJsUndefined(env); + } + + decltype(argc) convertArgc = 0; + AppExecFwk::FormInfoFilter filter; + napi_value jsValue = GetPropertyValueByPropertyName(env, argv[PARAM0], "supportedDimensions", napi_object); + if (jsValue != nullptr) { + std::vector dimensions; + UnwrapArrayInt32FromJS(env, jsValue, dimensions); + for (size_t i = 0; i < dimensions.size(); ++i) { + if (dimensions[i] < 0) { + HILOG_ERROR("dimensions value should not be negative"); + NapiFormUtil::ThrowParamError(env, "dimensions value should not be negative"); + return CreateJsUndefined(env); + } + filter.supportDimensions.emplace_back(dimensions[i]); + } + } + UnwrapStringByPropertyName(env, argv[PARAM0], "moduleName", filter.moduleName); + UnwrapStringByPropertyName(env, argv[PARAM0], "bundleName", filter.bundleName); + + convertArgc++; + auto complete = [filter](napi_env env, NapiAsyncTask &task, int32_t status) { + std::vector formInfos; + int ret = FormMgr::GetInstance().GetFormsInfoByFilter(filter, formInfos); + if (ret != ERR_OK) { + task.Reject(env, NapiFormUtil::CreateErrorByInternalErrorCode(env, ret)); + return; + } + task.ResolveWithNoError(env, CreateFormInfos(env, formInfos)); + }; + + napi_value result = nullptr; + napi_value lastParam = (argc <= convertArgc) ? nullptr : argv[convertArgc]; + NapiAsyncTask::ScheduleWithDefaultQos("JsFormHost::OnGetFormsInfo", + env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result)); + return result; + } + napi_value OnGetFormsInfo(napi_env env, size_t argc, napi_value* argv) { HILOG_DEBUG("%{public}s is called", __FUNCTION__); + if (argc == ARGS_ONE && IsTypeForNapiValue(env, argv[PARAM0], napi_object)) { + return GetFormsInfoByFilter(env, argc, argv); + } if (argc > ARGS_THREE || argc < ARGS_ONE) { HILOG_ERROR("wrong number of arguments."); NapiFormUtil::ThrowParamNumError(env, std::to_string(argc), "1 or 2 or 3"); return CreateJsUndefined(env); } - decltype(argc) convertArgc = 0; std::string bName(""); if (!ConvertFromJsValue(env, argv[PARAM0], bName)) { @@ -1270,7 +1318,6 @@ private: return CreateJsUndefined(env); } convertArgc++; - std::string mName(""); if ((argc == ARGS_TWO || argc == ARGS_THREE) && !IsTypeForNapiValue(env, argv[PARAM1], napi_function)) { if (!ConvertFromJsValue(env, argv[PARAM1], mName)) { @@ -1280,7 +1327,6 @@ private: } convertArgc++; } - auto complete = [bName, mName, convertArgc](napi_env env, NapiAsyncTask &task, int32_t status) { std::string bundleName(bName); std::string moduleName(mName); @@ -1291,14 +1337,12 @@ private: } else { ret = FormMgr::GetInstance().GetFormsInfoByModule(bundleName, moduleName, formInfos); } - if (ret != ERR_OK) { task.Reject(env, NapiFormUtil::CreateErrorByInternalErrorCode(env, ret)); return; } task.ResolveWithNoError(env, CreateFormInfos(env, formInfos)); }; - napi_value result = nullptr; napi_value lastParam = (argc <= convertArgc) ? nullptr : argv[convertArgc]; NapiAsyncTask::ScheduleWithDefaultQos("JsFormHost::OnGetFormsInfo", @@ -1887,4 +1931,4 @@ void JsFormRouterProxyMgr::RemoveFormRouterProxyCallback(const std::vector supportDimensions; /** * @brief Serialize the list of parameters for IPC. diff --git a/interfaces/inner_api/include/form_mgr_interface.h b/interfaces/inner_api/include/form_mgr_interface.h index c72d24aefa5f1aaab1e485cb364c31e088a78087..d3ee15001833dca65242776ecd67db989d124c99 100644 --- a/interfaces/inner_api/include/form_mgr_interface.h +++ b/interfaces/inner_api/include/form_mgr_interface.h @@ -292,6 +292,17 @@ public: virtual int GetFormsInfoByModule(std::string &bundleName, std::string &moduleName, std::vector &formInfos) = 0; + /** + * @brief Get forms info specfied by filter parameters. + * @param filter Filter that contains necessary conditions, such as bundle name, module name, dimensions. + * @param formInfos Return the forms' information specified by filter. + * @return Returns ERR_OK on success, others on failure. + */ + virtual int GetFormsInfoByFilter(const FormInfoFilter &filter, std::vector &formInfos) + { + return ERR_OK; + } + /** * @brief This function is called by formProvider and gets forms info by the bundle name of the calling ability. * The bundle name will be retrieved by form service manager. @@ -639,6 +650,7 @@ public: FORM_MGR_RECYCLE_FORMS, FORM_MGR_RECOVER_FORMS, FORM_MGR_HAS_FORM_VISIBLE_WITH_TOKENID, + FORM_MGR_GET_FORMS_INFO_BY_FILTER, }; }; } // namespace AppExecFwk diff --git a/interfaces/inner_api/include/form_mgr_proxy.h b/interfaces/inner_api/include/form_mgr_proxy.h index a4105d34f4cf2ec8c11a9d9191e357dedcf757a4..c8387cf5ca42e0d662c8b602a437a741a144a96a 100644 --- a/interfaces/inner_api/include/form_mgr_proxy.h +++ b/interfaces/inner_api/include/form_mgr_proxy.h @@ -279,6 +279,14 @@ public: virtual int GetFormsInfoByModule(std::string &bundleName, std::string &moduleName, std::vector &formInfos) override; + /** + * @brief Get forms info specfied by filter parameters. + * @param filter Filter that contains necessary conditions, such as bundle name, module name, dimensions. + * @param formInfos Return the forms' information specified by filter. + * @return Returns ERR_OK on success, others on failure. + */ + virtual int GetFormsInfoByFilter(const FormInfoFilter &filter, std::vector &formInfos) override; + /** * @brief This function is called by formProvider and gets forms info by the bundle name of the calling ability. * The bundle name will be retrieved by form service manager. diff --git a/interfaces/inner_api/include/form_mgr_stub.h b/interfaces/inner_api/include/form_mgr_stub.h index 4633155054d3b65eff0090d843b6efc75e0e91c9..1fe9b7bc42a662b4d083ccfd769c1ba9716bf937 100644 --- a/interfaces/inner_api/include/form_mgr_stub.h +++ b/interfaces/inner_api/include/form_mgr_stub.h @@ -251,6 +251,13 @@ private: * @return Returns ERR_OK on success, others on failure. */ int32_t HandleGetFormsInfoByModule(MessageParcel &data, MessageParcel &reply); + /** + * @brief Handle GetFormsInfoByModule message. + * @param data input param. + * @param reply output param. + * @return Returns ERR_OK on success, others on failure. + */ + int32_t HandleGetFormsInfoByFilter(MessageParcel &data, MessageParcel &reply); /** * @brief Handle GetFormsInfo message. * @param data input param. diff --git a/interfaces/inner_api/src/form_mgr_proxy.cpp b/interfaces/inner_api/src/form_mgr_proxy.cpp index 4075828de2072affb97caa610bc4a2231c4e5c6b..d3822a3847bbd3cb1002d6254e9d1ffa6dc811bf 100644 --- a/interfaces/inner_api/src/form_mgr_proxy.cpp +++ b/interfaces/inner_api/src/form_mgr_proxy.cpp @@ -1179,6 +1179,37 @@ int FormMgrProxy::GetFormsInfoByModule(std::string &bundleName, std::string &mod return error; } +int FormMgrProxy::GetFormsInfoByFilter(const FormInfoFilter &filter, std::vector &formInfos) +{ + MessageParcel data; + if (!WriteInterfaceToken(data)) { + HILOG_ERROR("%{public}s, failed to write interface token", __func__); + return ERR_APPEXECFWK_PARCEL_ERROR; + } + + if (!data.WriteString(filter.bundleName)) { + HILOG_ERROR("%{public}s, failed to write bundleName", __func__); + return ERR_APPEXECFWK_PARCEL_ERROR; + } + + if (!data.WriteString(filter.moduleName)) { + HILOG_ERROR("%{public}s, failed to write moduleName", __func__); + return ERR_APPEXECFWK_PARCEL_ERROR; + } + + if (!data.WriteInt32Vector(filter.supportDimensions)) { + HILOG_ERROR("Failed to write vector supportDimensions."); + return ERR_APPEXECFWK_PARCEL_ERROR; + } + + int error = GetFormsInfo(IFormMgr::Message::FORM_MGR_GET_FORMS_INFO_BY_FILTER, data, formInfos); + if (error != ERR_OK) { + HILOG_ERROR("%{public}s, failed to GetFormsInfoByFilter: %{public}d", __func__, error); + } + + return error; +} + ErrCode FormMgrProxy::GetRunningFormInfos(bool isUnusedInclude, std::vector &runningFormInfos) { MessageParcel data; diff --git a/interfaces/inner_api/src/form_mgr_stub.cpp b/interfaces/inner_api/src/form_mgr_stub.cpp index 12c4de3a9820323d18ef1c03e10d8a97a99f9c9e..5a5364e15d01c0b986f49adbfdf9fa22225493ad 100644 --- a/interfaces/inner_api/src/form_mgr_stub.cpp +++ b/interfaces/inner_api/src/form_mgr_stub.cpp @@ -88,6 +88,8 @@ FormMgrStub::FormMgrStub() &FormMgrStub::HandleGetFormsInfoByApp; memberFuncMap_[static_cast(IFormMgr::Message::FORM_MGR_GET_FORMS_INFO_BY_MODULE)] = &FormMgrStub::HandleGetFormsInfoByModule; + memberFuncMap_[static_cast(IFormMgr::Message::FORM_MGR_GET_FORMS_INFO_BY_FILTER)] = + &FormMgrStub::HandleGetFormsInfoByFilter; memberFuncMap_[static_cast(IFormMgr::Message::FORM_MGR_GET_FORMS_INFO)] = &FormMgrStub::HandleGetFormsInfo; memberFuncMap_[static_cast(IFormMgr::Message::FORM_MGR_ROUTER_EVENT)] = @@ -855,6 +857,24 @@ int32_t FormMgrStub::HandleGetFormsInfoByModule(MessageParcel &data, MessageParc return result; } +int32_t FormMgrStub::HandleGetFormsInfoByFilter(MessageParcel &data, MessageParcel &reply) +{ + HILOG_DEBUG("%{public}s called.", __func__); + FormInfoFilter filter; + filter.bundleName = data.ReadString(); + filter.moduleName = data.ReadString(); + data.ReadInt32Vector(&filter.supportDimensions); + + std::vector infos; + int32_t result = GetFormsInfoByFilter(filter, infos); + reply.WriteInt32(result); + if (result == ERR_OK && !WriteParcelableVector(infos, reply)) { + HILOG_ERROR("write failed"); + return ERR_APPEXECFWK_PARCEL_ERROR; + } + return result; +} + int32_t FormMgrStub::HandleGetFormsInfo(MessageParcel &data, MessageParcel &reply) { HILOG_INFO("%{public}s called.", __func__); diff --git a/interfaces/kits/native/include/form_mgr.h b/interfaces/kits/native/include/form_mgr.h index 14dccb27f572cc78505d581dcc78d3c4486997e5..91e490061e9d56258c43ad7786eefe150b5fc74e 100644 --- a/interfaces/kits/native/include/form_mgr.h +++ b/interfaces/kits/native/include/form_mgr.h @@ -382,6 +382,14 @@ public: */ int GetFormsInfoByModule(std::string &bundleName, std::string &moduleName, std::vector &formInfos); + /** + * @brief Get forms info specified by filter parameters. + * @param filter Filter that contains necessary conditions, such as bundle name, module name, dimensions. + * @param formInfos Return the forms' information specified by filter. + * @return Returns ERR_OK on success, others on failure. + */ + int GetFormsInfoByFilter(const FormInfoFilter &filter, std::vector &formInfos); + /** * @brief This function is called by formProvider and gets forms info by the bundle name of the calling ability. * The bundle name will be retrieved by form service manager. diff --git a/interfaces/kits/native/src/form_mgr.cpp b/interfaces/kits/native/src/form_mgr.cpp index da80ee7d0e089b4c3301797b0edd474667df3e71..9f5222f58f6596cd38b3b6a614a6ffaa564f5a0f 100644 --- a/interfaces/kits/native/src/form_mgr.cpp +++ b/interfaces/kits/native/src/form_mgr.cpp @@ -978,6 +978,21 @@ int FormMgr::GetFormsInfoByModule(std::string &bundleName, std::string &moduleNa } return resultCode; } + +int FormMgr::GetFormsInfoByFilter(const FormInfoFilter &filter, std::vector &formInfos) +{ + HILOG_DEBUG("called."); + int errCode = Connect(); + if (errCode != ERR_OK) { + return errCode; + } + int resultCode = remoteProxy_->GetFormsInfoByFilter(filter, formInfos); + if (resultCode != ERR_OK) { + HILOG_ERROR("failed to GetFormsInfoByFilter, error code is %{public}d.", resultCode); + } + return resultCode; +} + int32_t FormMgr::GetFormsInfo(const FormInfoFilter &filter, std::vector &formInfos) { HILOG_DEBUG("called."); diff --git a/services/include/form_info_mgr.h b/services/include/form_info_mgr.h index e5431ba509632856f1423b103c2366e3322fec06..f4cff0e9a7b4ac0799a884dfd60809d294b1ccf4 100644 --- a/services/include/form_info_mgr.h +++ b/services/include/form_info_mgr.h @@ -23,6 +23,7 @@ #include "appexecfwk_errors.h" #include "bundle_info.h" #include "form_info.h" +#include "form_info_filter.h" #include "form_info_storage.h" #include "form_record.h" #include "resource_manager.h" @@ -70,6 +71,9 @@ public: ErrCode GetFormsInfoByModule(const std::string &moduleName, std::vector &formInfos); + ErrCode GetFormsInfoByFilter( + const FormInfoFilter &filter, std::vector &formInfos, int32_t userId = Constants::INVALID_USER_ID); + private: ErrCode UpdateFormInfoStorageLocked(); @@ -98,6 +102,9 @@ public: ErrCode GetFormsInfoByModule(const std::string &bundleName, const std::string &moduleName, std::vector &formInfos); + ErrCode GetFormsInfoByFilter( + const FormInfoFilter &filter, std::vector &formInfos, int32_t userId = Constants::INVALID_USER_ID); + ErrCode GetFormsInfoByRecord(const FormRecord &formRecord, FormInfo &formInfo); ErrCode GetFormsInfoByModuleWithoutCheck(const std::string &bundleName, const std::string &moduleName, diff --git a/services/include/form_info_storage.h b/services/include/form_info_storage.h index 1c47fb837aeb6a3a1cc3cc541cdba10b707f9c3f..b21fe31012402419be3b3b800fca5c3e598c11b3 100644 --- a/services/include/form_info_storage.h +++ b/services/include/form_info_storage.h @@ -17,6 +17,7 @@ #define OHOS_FORM_FWK_FORM_INFO_STORAGE_H #include "form_info.h" +#include "form_info_filter.h" #include "nlohmann/json.hpp" namespace OHOS { @@ -32,6 +33,8 @@ struct FormInfoStorage { void GetAllFormsInfo(int32_t userId, std::vector &formInfos) const; void GetFormsInfoByModule(int32_t userId, const std::string &moduleName, std::vector &formInfos) const; + void GetFormsInfoByFilter(int32_t userId, + const AppExecFwk::FormInfoFilter &filter, std::vector &formInfos) const; }; void to_json(nlohmann::json &jsonObject, const FormInfoStorage &formInfoStorage); diff --git a/services/include/form_mgr_adapter.h b/services/include/form_mgr_adapter.h index f9a052a3bd35fa3cb4a58885c0dae30048d5d5a5..c62d08c36ed6cc2385949c68e7e9f08961d44ffa 100644 --- a/services/include/form_mgr_adapter.h +++ b/services/include/form_mgr_adapter.h @@ -22,6 +22,7 @@ #include "bundle_mgr_interface.h" #include "form_constants.h" #include "form_info.h" +#include "form_info_filter.h" #include "form_instance.h" #include "form_instances_filter.h" #include "form_item_info.h" @@ -360,6 +361,14 @@ public: int GetFormsInfoByModule(const std::string &bundleName, const std::string &moduleName, std::vector &formInfos); + /** + * @brief Get forms info specfied by filter parameters. + * @param filter Filter that contains necessary conditions, such as bundle name, module name, dimensions. + * @param formInfos Return the forms' information specified by filter. + * @return Returns ERR_OK on success, others on failure. + */ + int GetFormsInfoByFilter(const FormInfoFilter &filter, std::vector &formInfos); + /** * @brief get forms count. * @param isTempFormFlag Indicates temp form or not. diff --git a/services/include/form_mgr_service.h b/services/include/form_mgr_service.h index 0c56a5605548ffcf05c678db0bf712836164cb33..7119618665dba610f6df7fcc4b8040d1e1031d61 100644 --- a/services/include/form_mgr_service.h +++ b/services/include/form_mgr_service.h @@ -321,6 +321,14 @@ public: int GetFormsInfoByModule(std::string &bundleName, std::string &moduleName, std::vector &formInfos) override; + /** + * @brief This function is called by host and gets formsInfos info specifild by filter. + * @param filter Filter that contains necessary conditions, such as bundle name, module name, dimensions. + * @param formInfos Return the forms' information specified by filter. + * @return Returns ERR_OK on success, others on failure. + */ + int GetFormsInfoByFilter(const FormInfoFilter &filter, std::vector &formInfos) override; + /** * @brief This function is called by formProvider and gets forms info by the bundle name of the calling ability. * The bundle name will be retrieved here. diff --git a/services/src/form_info_mgr.cpp b/services/src/form_info_mgr.cpp index 6eee21257efbb0547b4503fcf3aaa6349efb8856..d0957ecb0e42a7b2edc99e6081df7dcdf163caa9 100644 --- a/services/src/form_info_mgr.cpp +++ b/services/src/form_info_mgr.cpp @@ -372,6 +372,19 @@ ErrCode BundleFormInfo::GetFormsInfoByModule(const std::string &moduleName, std: return ERR_OK; } +ErrCode BundleFormInfo::GetFormsInfoByFilter( + const FormInfoFilter &filter, std::vector &formInfos, int32_t userId) +{ + HILOG_DEBUG("%{public}s begin.", __func__); + std::shared_lock guard(formInfosMutex_); + auto newUserId = (userId == Constants::INVALID_USER_ID) ? FormUtil::GetCurrentAccountId() : userId; + + for (const auto &item : formInfoStorages_) { + item.GetFormsInfoByFilter(newUserId, filter, formInfos); + } + return ERR_OK; +} + ErrCode BundleFormInfo::UpdateFormInfoStorageLocked() { ErrCode errCode; @@ -494,6 +507,35 @@ ErrCode FormInfoMgr::GetAllFormsInfo(std::vector &formInfos) return ERR_OK; } +ErrCode FormInfoMgr::GetFormsInfoByFilter( + const FormInfoFilter &filter, std::vector &formInfos, int32_t userId) +{ + std::shared_lock guard(bundleFormInfoMapMutex_); + if (!CheckBundlePermission()) { + if (filter.bundleName.empty() || !IsCaller(filter.bundleName)) { + HILOG_ERROR("Permission is wrong."); + return ERR_APPEXECFWK_FORM_PERMISSION_DENY_BUNDLE; + } + } + if (filter.bundleName.empty()) { + for (const auto &bundleFormInfo : bundleFormInfoMap_) { + if (bundleFormInfo.second != nullptr) { + bundleFormInfo.second->GetFormsInfoByFilter(filter, formInfos, userId); + } + } + } else { + auto bundleFormInfoIter = bundleFormInfoMap_.find(filter.bundleName); + if (bundleFormInfoIter == bundleFormInfoMap_.end()) { + HILOG_WARN("no forms found for bundle name:%{public}s.", filter.bundleName.c_str()); + return ERR_OK; + } + if (bundleFormInfoIter->second != nullptr) { + bundleFormInfoIter->second->GetFormsInfoByFilter(filter, formInfos, userId); + } + } + return ERR_OK; +} + ErrCode FormInfoMgr::GetFormsInfoByBundle( const std::string &bundleName, std::vector &formInfos, int32_t userId) { diff --git a/services/src/form_info_storage.cpp b/services/src/form_info_storage.cpp index cbcb0847e3213ff12954616f4f537bbe2f2cd441..89ddce232f659155d29ae6106b6a89550dd9e1df 100644 --- a/services/src/form_info_storage.cpp +++ b/services/src/form_info_storage.cpp @@ -13,6 +13,8 @@ * limitations under the License. */ +#include "form_info.h" +#include "form_info_filter.h" #include "form_info_storage.h" #include "fms_log_wrapper.h" @@ -44,6 +46,43 @@ void FormInfoStorage::GetAllFormsInfo(int32_t userId, std::vector &targetDimensions, + const std::vector &supportDimensions, std::vector &results) +{ + for (const auto &val : supportDimensions) { + auto it = std::find(targetDimensions.begin(), targetDimensions.end(), val); + if (it != targetDimensions.end()) { + results.emplace_back(val); + } + } + return !results.empty(); +} + +void FormInfoStorage::GetFormsInfoByFilter(int32_t userId, + const AppExecFwk::FormInfoFilter &filter, std::vector &formInfos) const +{ + HILOG_DEBUG("called. current userId is:%{public}d, this userId is %{public}d.", userId, this->userId); + if (this->userId != userId && this->userId != AppExecFwk::Constants::DEFAULT_USERID) { + HILOG_ERROR("UserId is not valid."); + return; + } + for (const auto &item : this->formInfos) { + if (!filter.moduleName.empty() && filter.moduleName != item.moduleName) { + continue; + } + if (filter.supportDimensions.empty()) { + formInfos.emplace_back(item); + } else { + std::vector results; + if (find_match_dimensions(filter.supportDimensions, item.supportDimensions, results)) { + AppExecFwk::FormInfo formInfo = item; + formInfo.supportDimensions = results; + formInfos.emplace_back(formInfo); + } + } + } +} + void FormInfoStorage::GetFormsInfoByModule(int32_t userId, const std::string &moduleName, std::vector &formInfos) const { diff --git a/services/src/form_mgr_adapter.cpp b/services/src/form_mgr_adapter.cpp index 1ae73e96f528bb900491d62327e5579c150f06f2..556e2ad17eb86fa5557be287010bffb8f996875b 100644 --- a/services/src/form_mgr_adapter.cpp +++ b/services/src/form_mgr_adapter.cpp @@ -23,6 +23,7 @@ #include "ability_manager_errors.h" #include "form_record.h" +#include "form_info_filter.h" #include "accesstoken_kit.h" #include "hap_token_info.h" #ifdef DEVICE_USAGE_STATISTICS_ENABLE @@ -3025,6 +3026,18 @@ int FormMgrAdapter::GetFormsInfoByApp(const std::string &bundleName, std::vector return FormInfoMgr::GetInstance().GetFormsInfoByBundle(bundleName, formInfos); } +/** + * @brief Get forms info specified by filter parameters . + * @param filter Filter that contains necessary conditions, such as bundle name, module name, dimensions. + * @param formInfos Return the forms' information specified by filter. + * @return Returns ERR_OK on success, others on failure. + */ +int FormMgrAdapter::GetFormsInfoByFilter(const FormInfoFilter &filter, std::vector &formInfos) +{ + HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); + return FormInfoMgr::GetInstance().GetFormsInfoByFilter(filter, formInfos); +} + /** * @brief Get forms info by bundle name and module name. * @param bundleName bundle name. diff --git a/services/src/form_mgr_service.cpp b/services/src/form_mgr_service.cpp index 81368eefbf587b02cfa2136e2b73bd9ec9e0dec1..49b5461c826d33b3ec82257287cd028cff0bb864 100644 --- a/services/src/form_mgr_service.cpp +++ b/services/src/form_mgr_service.cpp @@ -958,6 +958,20 @@ int FormMgrService::GetFormsInfoByModule(std::string &bundleName, std::string &m return FormMgrAdapter::GetInstance().GetFormsInfoByModule(bundleName, moduleName, formInfos); } +int FormMgrService::GetFormsInfoByFilter(const FormInfoFilter &filter, std::vector &formInfos) +{ + HILOG_DEBUG("called."); + if (!CheckCallerIsSystemApp()) { + HILOG_ERROR("Need system authority"); + return ERR_APPEXECFWK_FORM_PERMISSION_DENY_SYS; + } + if (!CheckAcrossLocalAccountsPermission()) { + HILOG_ERROR("Across local accounts permission failed."); + return ERR_APPEXECFWK_FORM_PERMISSION_DENY; + } + return FormMgrAdapter::GetInstance().GetFormsInfoByFilter(filter, formInfos); +} + int32_t FormMgrService::GetFormsInfo(const FormInfoFilter &filter, std::vector &formInfos) { HILOG_INFO("called.");