diff --git a/interfaces/inner_api/appexecfwk_core/include/bundle_framework_core_ipc_interface_code.h b/interfaces/inner_api/appexecfwk_core/include/bundle_framework_core_ipc_interface_code.h index 5e692d53cf93f56a18610990d503fbd147eee7b6..dcbe12c6fd0eb0ed8c86cd2fa8160257945850bb 100644 --- a/interfaces/inner_api/appexecfwk_core/include/bundle_framework_core_ipc_interface_code.h +++ b/interfaces/inner_api/appexecfwk_core/include/bundle_framework_core_ipc_interface_code.h @@ -202,7 +202,7 @@ enum class BundleMgrInterfaceCode : uint32_t { SET_APP_DISTRIBUTION_TYPES = 176, MIGRATE_DATA = 177, GET_BUNDLE_ARCHIVE_INFO_EXT = 178, - QUERY_LAUNCHER_ABILITY_INFOS_PUBLIC = 179, + GET_LAUNCHER_ABILITY_INFO_SYNC = 179, }; /* SAID: 401-85 Interface No.85 subservice also provides the following interfaces */ diff --git a/interfaces/inner_api/appexecfwk_core/include/bundlemgr/bundle_mgr_host.h b/interfaces/inner_api/appexecfwk_core/include/bundlemgr/bundle_mgr_host.h index 428560a6e6aa2caee85cfe1faa1d316a80d0c3ba..86d37828015992591c563df79a92f68007529a28 100644 --- a/interfaces/inner_api/appexecfwk_core/include/bundlemgr/bundle_mgr_host.h +++ b/interfaces/inner_api/appexecfwk_core/include/bundlemgr/bundle_mgr_host.h @@ -306,12 +306,12 @@ private: */ ErrCode HandleQueryLauncherAbilityInfos(MessageParcel &data, MessageParcel &reply); /** - * @brief Handles the HandleQueryLauncherAbilityInfosPublic function called from a IBundleMgr proxy object. + * @brief Handles the HandleGetLauncherAbilityInfoSync function called from a IBundleMgr proxy object. * @param data Indicates the data to be read. * @param reply Indicates the reply to be sent; * @return Returns ERR_OK if called successfully; returns error code otherwise. */ - ErrCode HandleQueryLauncherAbilityInfosPublic(MessageParcel &data, MessageParcel &reply); + ErrCode HandleGetLauncherAbilityInfoSync(MessageParcel &data, MessageParcel &reply); /** * @brief Handles the HandleQueryAllAbilityInfos function called from a IBundleMgr proxy object. * @param data Indicates the data to be read. diff --git a/interfaces/inner_api/appexecfwk_core/include/bundlemgr/bundle_mgr_interface.h b/interfaces/inner_api/appexecfwk_core/include/bundlemgr/bundle_mgr_interface.h index 55f460e7c68de22e0a13006dc6e0ea88cb28e53a..d9420da873e9216711dcd698a65d2d8d61b74bbd 100644 --- a/interfaces/inner_api/appexecfwk_core/include/bundlemgr/bundle_mgr_interface.h +++ b/interfaces/inner_api/appexecfwk_core/include/bundlemgr/bundle_mgr_interface.h @@ -558,7 +558,7 @@ public: * @param abilityInfos Indicates the obtained AbilityInfos object. * @return Returns ERR_OK if the AbilityInfos is successfully obtained; returns errCode otherwise. */ - virtual ErrCode QueryLauncherAbilityInfosPublic( + virtual ErrCode GetLauncherAbilityInfoSync( const std::string &bundleName, int32_t userId, std::vector &abilityInfo) { return ERR_BUNDLE_MANAGER_INTERNAL_ERROR; diff --git a/interfaces/inner_api/appexecfwk_core/include/bundlemgr/bundle_mgr_proxy.h b/interfaces/inner_api/appexecfwk_core/include/bundlemgr/bundle_mgr_proxy.h index 1746f751538f30e94cb76ddccc7c463cb8ade3d6..bd87b85d99735aa497b796afc287759a15d3e580 100644 --- a/interfaces/inner_api/appexecfwk_core/include/bundlemgr/bundle_mgr_proxy.h +++ b/interfaces/inner_api/appexecfwk_core/include/bundlemgr/bundle_mgr_proxy.h @@ -408,7 +408,7 @@ public: * @param abilityInfos Indicates the obtained AbilityInfos object. * @return Returns ERR_OK if the AbilityInfos is successfully obtained; returns errCode otherwise. */ - virtual ErrCode QueryLauncherAbilityInfosPublic( + virtual ErrCode GetLauncherAbilityInfoSync( const std::string &bundleName, int32_t userId, std::vector &abilityInfo) override; /** * @brief Query the AbilityInfo of list for all service on launcher. diff --git a/interfaces/inner_api/appexecfwk_core/include/bundlemgr/launcher_service.h b/interfaces/inner_api/appexecfwk_core/include/bundlemgr/launcher_service.h index da0755a2054e8288c10a3082d84e1a0db0faeb6b..77fb4273b099ef8a7eeb941f6229b8db61c3c780 100644 --- a/interfaces/inner_api/appexecfwk_core/include/bundlemgr/launcher_service.h +++ b/interfaces/inner_api/appexecfwk_core/include/bundlemgr/launcher_service.h @@ -92,7 +92,7 @@ public: * @param launcherAbilityInfos Indicates the obtained vector of the input bundle. * @return Returns ERR code of the result. */ - ErrCode GetLauncherAbilityByBundleNamePublic(const std::string &bundleName, const int32_t userId, + ErrCode GetLauncherAbilityInfoSync(const std::string &bundleName, const int32_t userId, std::vector &launcherAbilityInfos); /** * @brief Obtains information about the launcher ability of input bundleName and userId. diff --git a/interfaces/inner_api/appexecfwk_core/src/bundlemgr/bundle_mgr_host.cpp b/interfaces/inner_api/appexecfwk_core/src/bundlemgr/bundle_mgr_host.cpp index 81926e049718e7864ea1c17991b752920189b49f..e87e7a27551bfb462353cf3efa70d239d6b084cd 100644 --- a/interfaces/inner_api/appexecfwk_core/src/bundlemgr/bundle_mgr_host.cpp +++ b/interfaces/inner_api/appexecfwk_core/src/bundlemgr/bundle_mgr_host.cpp @@ -198,8 +198,8 @@ int BundleMgrHost::OnRemoteRequest(uint32_t code, MessageParcel &data, MessagePa case static_cast(BundleMgrInterfaceCode::QUERY_LAUNCHER_ABILITY_INFO): errCode = this->HandleQueryLauncherAbilityInfos(data, reply); break; - case static_cast(BundleMgrInterfaceCode::QUERY_LAUNCHER_ABILITY_INFOS_PUBLIC): - errCode = this->HandleQueryLauncherAbilityInfosPublic(data, reply); + case static_cast(BundleMgrInterfaceCode::GET_LAUNCHER_ABILITY_INFO_SYNC): + errCode = this->HandleGetLauncherAbilityInfoSync(data, reply); break; case static_cast(BundleMgrInterfaceCode::QUERY_ALL_ABILITY_INFOS): errCode = this->HandleQueryAllAbilityInfos(data, reply); @@ -1400,12 +1400,12 @@ ErrCode BundleMgrHost::HandleQueryLauncherAbilityInfos(MessageParcel &data, Mess return ERR_OK; } -ErrCode BundleMgrHost::HandleQueryLauncherAbilityInfosPublic(MessageParcel &data, MessageParcel &reply) +ErrCode BundleMgrHost::HandleGetLauncherAbilityInfoSync(MessageParcel &data, MessageParcel &reply) { std::string bundleName = data.ReadString(); int32_t userId = data.ReadInt32(); std::vector abilityInfos; - ErrCode ret = QueryLauncherAbilityInfosPublic(bundleName, userId, abilityInfos); + ErrCode ret = GetLauncherAbilityInfoSync(bundleName, userId, abilityInfos); if (!reply.WriteInt32(ret)) { APP_LOGE("write ret failed"); return ERR_APPEXECFWK_PARCEL_ERROR; diff --git a/interfaces/inner_api/appexecfwk_core/src/bundlemgr/bundle_mgr_proxy.cpp b/interfaces/inner_api/appexecfwk_core/src/bundlemgr/bundle_mgr_proxy.cpp index 91604794f8e2671cc6401358434d863a4234d989..b60fc8000ade9ce316ce4f22789abc09201636e9 100644 --- a/interfaces/inner_api/appexecfwk_core/src/bundlemgr/bundle_mgr_proxy.cpp +++ b/interfaces/inner_api/appexecfwk_core/src/bundlemgr/bundle_mgr_proxy.cpp @@ -1263,7 +1263,7 @@ ErrCode BundleMgrProxy::QueryLauncherAbilityInfos( BundleMgrInterfaceCode::QUERY_LAUNCHER_ABILITY_INFO, data, abilityInfo); } -ErrCode BundleMgrProxy::QueryLauncherAbilityInfosPublic( +ErrCode BundleMgrProxy::GetLauncherAbilityInfoSync( const std::string &bundleName, int32_t userId, std::vector &abilityInfo) { HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__); @@ -1281,7 +1281,7 @@ ErrCode BundleMgrProxy::QueryLauncherAbilityInfosPublic( return ERR_APPEXECFWK_PARCEL_ERROR; } return GetVectorFromParcelIntelligentWithErrCode( - BundleMgrInterfaceCode::QUERY_LAUNCHER_ABILITY_INFOS_PUBLIC, data, abilityInfo); + BundleMgrInterfaceCode::GET_LAUNCHER_ABILITY_INFO_SYNC, data, abilityInfo); } bool BundleMgrProxy::QueryAllAbilityInfos(const Want &want, int32_t userId, std::vector &abilityInfos) diff --git a/interfaces/inner_api/appexecfwk_core/src/bundlemgr/launcher_service.cpp b/interfaces/inner_api/appexecfwk_core/src/bundlemgr/launcher_service.cpp index 004caef4dcd294d5bc664311c5eeff2ce51026e5..22aa295eef33535780efd675686acc4582464165 100644 --- a/interfaces/inner_api/appexecfwk_core/src/bundlemgr/launcher_service.cpp +++ b/interfaces/inner_api/appexecfwk_core/src/bundlemgr/launcher_service.cpp @@ -339,11 +339,11 @@ ErrCode LauncherService::GetLauncherAbilityByBundleName(const std::string &bundl return ERR_OK; } -ErrCode LauncherService::GetLauncherAbilityByBundleNamePublic(const std::string &bundleName, const int32_t userId, +ErrCode LauncherService::GetLauncherAbilityInfoSync(const std::string &bundleName, const int32_t userId, std::vector &launcherAbilityInfos) { HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__); - APP_LOGD("GetLauncherAbilityByBundleNamePublic called"); + APP_LOGD("GetLauncherAbilityInfoSync called"); if (bundleName.empty()) { APP_LOGE("no bundleName %{public}s found", bundleName.c_str()); return ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST; @@ -355,9 +355,9 @@ ErrCode LauncherService::GetLauncherAbilityByBundleNamePublic(const std::string } std::vector abilityInfos; - ErrCode err = iBundleMgr->QueryLauncherAbilityInfosPublic(bundleName, userId, abilityInfos); + ErrCode err = iBundleMgr->GetLauncherAbilityInfoSync(bundleName, userId, abilityInfos); if (err != ERR_OK) { - APP_LOGE_NOFUNC("QueryLauncherAbilityInfosPublic fail:%{public}d -n %{public}s", err, bundleName.c_str()); + APP_LOGE_NOFUNC("GetLauncherAbilityInfoSync fail:%{public}d -n %{public}s", err, bundleName.c_str()); return err; } for (const auto &ability : abilityInfos) { diff --git a/interfaces/kits/js/launcher_bundle_manager/launcher_bundle_manager.cpp b/interfaces/kits/js/launcher_bundle_manager/launcher_bundle_manager.cpp index ac7b730e5104e17d4ccbf0d0bb5026519b968e19..a824b1de6d029d90cae2cad42331e9ea0f61b616 100644 --- a/interfaces/kits/js/launcher_bundle_manager/launcher_bundle_manager.cpp +++ b/interfaces/kits/js/launcher_bundle_manager/launcher_bundle_manager.cpp @@ -171,9 +171,9 @@ napi_value GetLauncherAbilityInfoSync(napi_env env, napi_callback_info info) } std::vector launcherAbilityInfos; ErrCode ret = CommonFunc::ConvertErrCode(launcherService-> - GetLauncherAbilityByBundleNamePublic(bundleName, userId, launcherAbilityInfos)); + GetLauncherAbilityInfoSync(bundleName, userId, launcherAbilityInfos)); if (ret != SUCCESS) { - APP_LOGE("GetLauncherAbilityByBundleNamePublic failed, bundleName is %{public}s, userId is %{public}d", + APP_LOGE("GetLauncherAbilityInfoSync failed, bundleName is %{public}s, userId is %{public}d", bundleName.c_str(), userId); napi_value businessError = BusinessError::CreateCommonError( env, ret, GET_LAUNCHER_ABILITY_INFO_SYNC, Constants::PERMISSION_GET_BUNDLE_INFO_PRIVILEGED); diff --git a/services/bundlemgr/include/bundle_data_mgr.h b/services/bundlemgr/include/bundle_data_mgr.h index dcf6174e189285aa25559839bf66dfa46a4cda21..094176d3cec72231141700f458a004c75e7a0cca 100644 --- a/services/bundlemgr/include/bundle_data_mgr.h +++ b/services/bundlemgr/include/bundle_data_mgr.h @@ -206,6 +206,15 @@ public: */ ErrCode QueryLauncherAbilityInfos( const Want &want, int32_t userId, std::vector &abilityInfos) const; + /** + * @brief Query Launcher AbilityInfo of list by the given Want. + * @param bundleName Indicates the information of the ability. + * @param userId Indicates the user ID. + * @param abilityInfos Indicates the obtained AbilityInfo of list. + * @return Returns ERR_OK if the AbilityInfo is successfully obtained; returns errCode otherwise. + */ + ErrCode GetLauncherAbilityInfoSync( + const Want &want, int32_t userId, std::vector &abilityInfos) const; /** * @brief Query all match launcher ability infos by given wants. * @param want Indicates the match infomation for abilities. diff --git a/services/bundlemgr/include/bundle_mgr_host_impl.h b/services/bundlemgr/include/bundle_mgr_host_impl.h index 8cdb5615fedc52c77f7dbdffcee7c420b58450fb..719ffe5ad3b164e6649ba73cb1eb3ed815baecb3 100644 --- a/services/bundlemgr/include/bundle_mgr_host_impl.h +++ b/services/bundlemgr/include/bundle_mgr_host_impl.h @@ -390,7 +390,7 @@ public: * @param abilityInfos Indicates the obtained AbilityInfos object. * @return Returns ERR_OK if the AbilityInfos is successfully obtained; returns errCode otherwise. */ - virtual ErrCode QueryLauncherAbilityInfosPublic(const std::string &bundleName, + virtual ErrCode GetLauncherAbilityInfoSync(const std::string &bundleName, int32_t userId, std::vector &abilityInfos) override; /** * @brief Query the AbilityInfo of list of all service on launcher. diff --git a/services/bundlemgr/src/bundle_data_mgr.cpp b/services/bundlemgr/src/bundle_data_mgr.cpp index 6febfd68f2d00308625bf03721d9b4f3faaf63fd..7546d69746145d9cfe562552548e59deb374e60f 100644 --- a/services/bundlemgr/src/bundle_data_mgr.cpp +++ b/services/bundlemgr/src/bundle_data_mgr.cpp @@ -2297,12 +2297,6 @@ ErrCode BundleDataMgr::GetLauncherAbilityByBundleName(const Want &want, std::vec return ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST; } const InnerBundleInfo &info = item->second; - if(!BundlePermissionMgr::IsSystemApp()){ - int32_t responseUserId = info.GetResponseUserId(userId); - if (responseUserId == Constants::INVALID_USERID) { - return ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST; - } - } if (info.IsDisabled()) { LOG_W(BMS_TAG_QUERY, "app %{public}s is disabled", info.GetBundleName().c_str()); return ERR_BUNDLE_MANAGER_BUNDLE_DISABLED; @@ -2360,6 +2354,57 @@ ErrCode BundleDataMgr::QueryLauncherAbilityInfos( return ret; } +ErrCode BundleDataMgr::GetLauncherAbilityInfoSync(const Want &want, const int32_t userId, + std::vector &abilityInfos) const +{ + int32_t requestUserId = GetUserId(userId); + if (requestUserId == Constants::INVALID_USERID) { + LOG_E(BMS_TAG_QUERY, "request user id is invalid"); + return ERR_BUNDLE_MANAGER_INVALID_USER_ID; + } + std::shared_lock lock(bundleInfoMutex_); + ElementName element = want.GetElement(); + std::string bundleName = element.GetBundleName(); + const auto &item = bundleInfos_.find(bundleName); + if (item == bundleInfos_.end()) { + LOG_W(BMS_TAG_QUERY, "no bundleName %{public}s found", bundleName.c_str()); + return ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST; + } + const InnerBundleInfo &info = item->second; + if(!BundlePermissionMgr::IsSystemApp()){ + int32_t responseUserId = info.GetResponseUserId(userId); + if (responseUserId == Constants::INVALID_USERID) { + return ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST; + } + } + if (info.IsDisabled()) { + LOG_W(BMS_TAG_QUERY, "app %{public}s is disabled", info.GetBundleName().c_str()); + return ERR_BUNDLE_MANAGER_BUNDLE_DISABLED; + } + if (info.GetBaseApplicationInfo().hideDesktopIcon) { + LOG_D(BMS_TAG_QUERY, "Bundle(%{public}s) hide desktop icon", bundleName.c_str()); + return ERR_OK; + } + if (info.GetBaseBundleInfo().entryInstallationFree) { + LOG_D(BMS_TAG_QUERY, "Bundle(%{public}s) is atomic service, hide desktop icon", bundleName.c_str()); + return ERR_OK; + } + // get installTime from innerBundleUserInfo + int64_t installTime = 0; + std::string userIdKey = info.GetBundleName() + "_" + std::to_string(userId); + std::string userZeroKey = info.GetBundleName() + "_" + std::to_string(0); + auto iter = std::find_if(info.GetInnerBundleUserInfos().begin(), info.GetInnerBundleUserInfos().end(), + [&userIdKey, &userZeroKey](const std::pair &infoMap) { + return (infoMap.first == userIdKey || infoMap.first == userZeroKey); + }); + if (iter != info.GetInnerBundleUserInfos().end()) { + installTime = iter->second.installTime; + } + GetMatchLauncherAbilityInfos(want, item->second, abilityInfos, installTime, userId); + FilterAbilityInfosByModuleName(element.GetModuleName(), abilityInfos); + return ERR_OK; +} + bool BundleDataMgr::QueryAbilityInfoByUri( const std::string &abilityUri, int32_t userId, AbilityInfo &abilityInfo) const { diff --git a/services/bundlemgr/src/bundle_mgr_host_impl.cpp b/services/bundlemgr/src/bundle_mgr_host_impl.cpp index 374e294440a1ac5933c37a745198e79a221e6a5a..5e86a74f24b8ce3b4ed7e74721fc7ef32742fd44 100644 --- a/services/bundlemgr/src/bundle_mgr_host_impl.cpp +++ b/services/bundlemgr/src/bundle_mgr_host_impl.cpp @@ -997,17 +997,17 @@ ErrCode BundleMgrHostImpl::QueryLauncherAbilityInfos( return ret; } -ErrCode BundleMgrHostImpl::QueryLauncherAbilityInfosPublic( +ErrCode BundleMgrHostImpl::GetLauncherAbilityInfoSync( const std::string &bundleName, int32_t userId, std::vector &abilityInfos) { HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__); - LOG_D(BMS_TAG_QUERY, "start QueryLauncherAbilityInfosPublic, userId : %{public}d", userId); + LOG_D(BMS_TAG_QUERY, "start GetLauncherAbilityInfoSync, userId : %{public}d", userId); if (!BundlePermissionMgr::VerifyCallingPermissionForAll(Constants::PERMISSION_GET_BUNDLE_INFO_PRIVILEGED)) { LOG_E(BMS_TAG_QUERY, "verify permission failed"); return ERR_BUNDLE_MANAGER_PERMISSION_DENIED; } - APP_LOGD("verify permission success, begin to QueryLauncherAbilityInfosPublic"); + APP_LOGD("verify permission success, begin to GetLauncherAbilityInfoSync"); auto dataMgr = GetDataMgrFromService(); if (dataMgr == nullptr) { LOG_E(BMS_TAG_QUERY, "DataMgr is nullptr"); @@ -1024,7 +1024,7 @@ ErrCode BundleMgrHostImpl::QueryLauncherAbilityInfosPublic( elementName.SetBundleName(bundleName); want.SetElement(elementName); - auto ret = dataMgr->QueryLauncherAbilityInfos(want, userId, abilityInfos); + auto ret = dataMgr->GetLauncherAbilityInfoSync(want, userId, abilityInfos); auto bmsExtensionClient = std::make_shared(); if (bmsExtensionClient->QueryLauncherAbility(want, userId, abilityInfos) == ERR_OK) { LOG_D(BMS_TAG_QUERY, "query launcher ability infos from bms extension successfully"); diff --git a/services/bundlemgr/test/unittest/bms_bundle_kit_service_test/bms_bundle_data_mgr_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_kit_service_test/bms_bundle_data_mgr_test.cpp index 6fb8494dec9e898db5f2f1ed26c58201186da1a7..871aa4199183f895ebf1db833dbe026d164c0a9e 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_kit_service_test/bms_bundle_data_mgr_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_kit_service_test/bms_bundle_data_mgr_test.cpp @@ -1189,6 +1189,106 @@ HWTEST_F(BmsBundleDataMgrTest, GetLauncherAbilityByBundleName_0300, Function | S EXPECT_EQ(res, ERR_OK); } +/** + * @tc.number: GetLauncherAbilityInfoSync_0100 + * @tc.name: test GetLauncherAbilityInfoSync + * @tc.desc: 1.system run normally + * 2.check GetLauncherAbilityInfoSync true + */ +HWTEST_F(BmsBundleDataMgrTest, GetLauncherAbilityInfoSync_0100, Function | SmallTest | Level1) +{ + Want want; + want.SetElementName(BUNDLE_TEST1, ABILITY_NAME_TEST); + std::vector abilityInfo; + InnerBundleInfo innerBundleInfo; + BundleInfo bundleInfo; + bundleInfo.entryInstallationFree = true; + innerBundleInfo.SetBaseBundleInfo(bundleInfo); + GetBundleDataMgr()->bundleInfos_.emplace(BUNDLE_TEST1, innerBundleInfo); + ErrCode res = GetBundleDataMgr()->GetLauncherAbilityInfoSync(want, USERID, abilityInfo); + EXPECT_NE(res, ERR_OK); +} + +/** + * @tc.number: GetLauncherAbilityInfoSync_0200 + * @tc.name: test GetLauncherAbilityInfoSync + * @tc.desc: 1.system run normally + * 2.check GetLauncherAbilityInfoSync failed + */ +HWTEST_F(BmsBundleDataMgrTest, GetLauncherAbilityInfoSync_0200, Function | SmallTest | Level1) +{ + Want want; + want.SetElementName(BUNDLE_TEST1, ABILITY_NAME_TEST); + std::vector abilityInfo; + InnerBundleInfo innerBundleInfo; + GetBundleDataMgr()->bundleInfos_.emplace("", innerBundleInfo); + ErrCode res = GetBundleDataMgr()->GetLauncherAbilityInfoSync(want, USERID, abilityInfo); + EXPECT_NE(res, ERR_OK); +} + +/** + * @tc.number: GetLauncherAbilityInfoSync_0300 + * @tc.name: test GetLauncherAbilityInfoSync + * @tc.desc: 1.system run normally + * 2.check GetLauncherAbilityInfoSync failed + */ +HWTEST_F(BmsBundleDataMgrTest, GetLauncherAbilityInfoSync_0300, Function | SmallTest | Level1) +{ + Want want; + want.SetElementName(BUNDLE_TEST1, ABILITY_NAME_TEST); + std::vector abilityInfo; + InnerBundleInfo innerBundleInfo; + BundleInfo bundleInfo; + bundleInfo.entryInstallationFree = true; + innerBundleInfo.SetBaseBundleInfo(bundleInfo); + GetBundleDataMgr()->bundleInfos_.emplace(BUNDLE_TEST1, innerBundleInfo); + ErrCode res = GetBundleDataMgr()->GetLauncherAbilityInfoSync(want, -1, abilityInfo); + EXPECT_NE(res, ERR_OK); +} + +/** + * @tc.number: GetLauncherAbilityInfoSync_0400 + * @tc.name: test GetLauncherAbilityInfoSync + * @tc.desc: 1.system run normally + * 2.check GetLauncherAbilityInfoSync true + */ +HWTEST_F(BmsBundleDataMgrTest, GetLauncherAbilityInfoSync_0400, Function | SmallTest | Level1) +{ + Want want; + want.SetElementName(BUNDLE_TEST1, ABILITY_NAME_TEST); + std::vector abilityInfo; + InnerBundleInfo innerBundleInfo; + ApplicationInfo applicationInfo; + applicationInfo.hideDesktopIcon = true; + innerBundleInfo.SetBaseApplicationInfo(applicationInfo); + GetBundleDataMgr()->bundleInfos_.emplace(BUNDLE_TEST1, innerBundleInfo); + ErrCode res = GetBundleDataMgr()->GetLauncherAbilityInfoSync(want, USERID, abilityInfo); + EXPECT_NE(res, ERR_OK); +} + +/** + * @tc.number: GetLauncherAbilityInfoSync_0500 + * @tc.name: test GetLauncherAbilityInfoSync + * @tc.desc: 1.system run normally + * 2.check GetLauncherAbilityInfoSync true + */ +HWTEST_F(BmsBundleDataMgrTest, GetLauncherAbilityInfoSync_0500, Function | SmallTest | Level1) +{ + Want want; + want.SetElementName(BUNDLE_TEST1, ABILITY_NAME_TEST); + std::vector abilityInfo; + InnerBundleInfo innerBundleInfo; + ApplicationInfo applicationInfo; + applicationInfo.hideDesktopIcon = false; + innerBundleInfo.SetBaseApplicationInfo(applicationInfo); + BundleInfo bundleInfo; + bundleInfo.entryInstallationFree = false; + innerBundleInfo.SetBaseBundleInfo(bundleInfo); + GetBundleDataMgr()->bundleInfos_.emplace(BUNDLE_TEST1, innerBundleInfo); + ErrCode res = GetBundleDataMgr()->GetLauncherAbilityInfoSync(want, USERID, abilityInfo); + EXPECT_NE(res, ERR_OK); +} + /** * @tc.number: QueryAbilityInfoByUri_0100 * @tc.name: test QueryAbilityInfoByUri diff --git a/services/bundlemgr/test/unittest/bms_bundle_manager_test/bms_bundle_manager_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_manager_test/bms_bundle_manager_test.cpp index cf7001f96aa85719db57595db3d878cb1f0d2b5e..715911d846fff420e2520aa34cc6d233e6123be3 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_manager_test/bms_bundle_manager_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_manager_test/bms_bundle_manager_test.cpp @@ -3069,7 +3069,7 @@ HWTEST_F(BmsBundleManagerTest, BundleMgrHostImpl_1200, Function | MediumTest | L retCode = hostImpl->QueryLauncherAbilityInfos(want, USERID, abilityInfos); EXPECT_EQ(retCode, ERR_BUNDLE_MANAGER_INTERNAL_ERROR); - retCode = hostImpl->QueryLauncherAbilityInfosPublic("", USERID, abilityInfos); + retCode = hostImpl->GetLauncherAbilityInfoSync("", USERID, abilityInfos); EXPECT_EQ(retCode, ERR_BUNDLE_MANAGER_INTERNAL_ERROR); retBool = hostImpl->IsPreInstallApp(""); @@ -4299,7 +4299,7 @@ HWTEST_F(BmsBundleManagerTest, GetMgrFalseByNoBundle_0018, Function | SmallTest /** * @tc.number: GetMgrFalseByNoBundle_0020 - * @tc.name: test QueryLauncherAbilityInfosPublic + * @tc.name: test GetLauncherAbilityInfoSync * @tc.desc: 1.system run normally * 2.bundle is empty */ @@ -4308,7 +4308,7 @@ HWTEST_F(BmsBundleManagerTest, GetMgrFalseByNoBundle_0020, Function | SmallTest auto hostImpl = std::make_unique(); std::string bundleName = "action.system.home"; std::vector abilityInfos; - ErrCode testRet = hostImpl->QueryLauncherAbilityInfosPublic( + ErrCode testRet = hostImpl->GetLauncherAbilityInfoSync( bundleName, USERID, abilityInfos); EXPECT_EQ(testRet, ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST); } diff --git a/services/bundlemgr/test/unittest/bms_bundle_mgr_proxy_test/bms_bundle_mgr_proxy_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_mgr_proxy_test/bms_bundle_mgr_proxy_test.cpp index fec8787aeb58fca3790fb2ffcdc4933d87af527f..4765bcd5ff01c13c51cf5aef8f4b487a7c696b6a 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_mgr_proxy_test/bms_bundle_mgr_proxy_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_mgr_proxy_test/bms_bundle_mgr_proxy_test.cpp @@ -798,19 +798,19 @@ HWTEST_F(BmsBundleMgrProxyTest, QueryLauncherAbilityInfos_0100, Function | Mediu } /** - * @tc.number: QueryLauncherAbilityInfosPublic_0100 - * @tc.name: test the QueryLauncherAbilityInfosPublic + * @tc.number: GetLauncherAbilityInfoSync_0100 + * @tc.name: test the GetLauncherAbilityInfoSync * @tc.desc: 1. system running normally - * 2. test QueryLauncherAbilityInfosPublic + * 2. test GetLauncherAbilityInfoSync */ -HWTEST_F(BmsBundleMgrProxyTest, QueryLauncherAbilityInfosPublic_0100, Function | MediumTest | Level1) +HWTEST_F(BmsBundleMgrProxyTest, GetLauncherAbilityInfoSync_0100, Function | MediumTest | Level1) { sptr impl; BundleMgrProxy bundleMgrProxy(impl); std::string bundleName; int32_t userId = 100; std::vector abilityInfos; - auto res = bundleMgrProxy.QueryLauncherAbilityInfosPublic(bundleName, userId, abilityInfos); + auto res = bundleMgrProxy.GetLauncherAbilityInfoSync(bundleName, userId, abilityInfos); EXPECT_NE(res, ERR_OK); } diff --git a/services/bundlemgr/test/unittest/bms_bundle_permission_grant_test/bms_bundle_permission_false_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_permission_grant_test/bms_bundle_permission_false_test.cpp index 1829ddab2347ed9a8a175333bedd28dca231b2a5..b1344018eb7beb47e9d53223581897cd40a1f962 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_permission_grant_test/bms_bundle_permission_false_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_permission_grant_test/bms_bundle_permission_false_test.cpp @@ -1724,14 +1724,14 @@ HWTEST_F(BmsBundlePermissionFalseTest, BmsBundlePermissionFalseTest_27000, Funct /** * @tc.number: BmsBundlePermissionFalseTest_28000 - * @tc.name: test QueryLauncherAbilityInfosPublic + * @tc.name: test GetLauncherAbilityInfoSync * @tc.desc: 1.system run normally * 2.bundleInfos is empty */ HWTEST_F(BmsBundlePermissionFalseTest, BmsBundlePermissionFalseTest_28000, Function | SmallTest | Level1) { std::vector abilityInfos; - ErrCode testRet = bundleMgrHostImpl_->QueryLauncherAbilityInfosPublic("", USERID, abilityInfos); + ErrCode testRet = bundleMgrHostImpl_->GetLauncherAbilityInfoSync("", USERID, abilityInfos); EXPECT_EQ(testRet, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); } diff --git a/services/bundlemgr/test/unittest/bms_bundle_permission_grant_test/bms_bundle_permission_system_app_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_permission_grant_test/bms_bundle_permission_system_app_test.cpp index 4d5da1deda4282099f04c0e992c6a2573c04e89e..024a26e3ec3476bbdb144170f4845ac931ed0357 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_permission_grant_test/bms_bundle_permission_system_app_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_permission_grant_test/bms_bundle_permission_system_app_test.cpp @@ -1344,14 +1344,14 @@ HWTEST_F(BmsBundlePermissionSyetemAppFalseTest, BmsBundleSyetemAppFalseTest_8500 /** * @tc.number: BmsBundleSyetemAppFalseTest_8600 - * @tc.name: test QueryLauncherAbilityInfosPublic + * @tc.name: test GetLauncherAbilityInfoSync * @tc.desc: 1.system run normally * 2.bundleInfos is empty */ HWTEST_F(BmsBundlePermissionSyetemAppFalseTest, BmsBundleSyetemAppFalseTest_8600, Function | SmallTest | Level1) { std::vector abilityInfos; - ErrCode testRet = bundleMgrHostImpl_->QueryLauncherAbilityInfosPublic("", USERID, abilityInfos); + ErrCode testRet = bundleMgrHostImpl_->GetLauncherAbilityInfoSync("", USERID, abilityInfos); EXPECT_NE(testRet, ERR_BUNDLE_MANAGER_SYSTEM_API_DENIED); } @@ -1414,16 +1414,16 @@ HWTEST_F(BmsBundlePermissionSyetemAppFalseTest, QueryLauncherAbilityInfosTest, F } /** - * @tc.number: QueryLauncherAbilityInfosPublicTest - * @tc.name: test QueryLauncherAbilityInfosPublic of BundleMgrProxy + * @tc.number: GetLauncherAbilityInfoSyncTest + * @tc.name: test GetLauncherAbilityInfoSync of BundleMgrProxy * @tc.desc: system running normally */ -HWTEST_F(BmsBundlePermissionSyetemAppFalseTest, QueryLauncherAbilityInfosPublicTest, Function | SmallTest | Level0) +HWTEST_F(BmsBundlePermissionSyetemAppFalseTest, GetLauncherAbilityInfoSyncTest, Function | SmallTest | Level0) { auto bundleMgrProxy = GetBundleMgrProxy(); ASSERT_NE(bundleMgrProxy, nullptr); std::vector abilityInfos; - auto result = bundleMgrProxy->QueryLauncherAbilityInfosPublic(BUNDLE_NAME, USERID, abilityInfos); + auto result = bundleMgrProxy->GetLauncherAbilityInfoSync(BUNDLE_NAME, USERID, abilityInfos); EXPECT_NE(result, ERR_OK); } diff --git a/test/systemtest/common/bms/bms_launcher_service_system_test/bms_launcher_service_system_test.cpp b/test/systemtest/common/bms/bms_launcher_service_system_test/bms_launcher_service_system_test.cpp index ae6f418a6e314dec3316e99985ae57283d45a9e6..ee7c32aae1d52a614713b6d6d21efde519a6b9d7 100755 --- a/test/systemtest/common/bms/bms_launcher_service_system_test/bms_launcher_service_system_test.cpp +++ b/test/systemtest/common/bms/bms_launcher_service_system_test/bms_launcher_service_system_test.cpp @@ -951,15 +951,15 @@ HWTEST_F(BmsLauncherServiceSystemTest, BMS_GetLauncherAbilityByBundleName_0200, } /** - * @tc.number: BMS_GetLauncherAbilityByBundleNamePublic_0100 + * @tc.number: BMS_GetLauncherAbilityInfoSync_0100 * @tc.name: test GetAbilityInfo by LauncherService * @tc.desc: 1.install a low version hap * 2.install a high version hap * 3.get the application info of the high version hap by bundleName */ -HWTEST_F(BmsLauncherServiceSystemTest, BMS_GetLauncherAbilityByBundleNamePublic_0100, Function | MediumTest | Level1) +HWTEST_F(BmsLauncherServiceSystemTest, BMS_GetLauncherAbilityInfoSync_0100, Function | MediumTest | Level1) { - GTEST_LOG_(INFO) << "START BMS_GetLauncherAbilityByBundleNamePublic_0100"; + GTEST_LOG_(INFO) << "START BMS_GetLauncherAbilityInfoSync_0100"; std::string bundleName = TEST_BUNDLE_NAME; std::string bundleFilePath1 = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap"; std::vector launcherAbilityInfos; @@ -969,7 +969,7 @@ HWTEST_F(BmsLauncherServiceSystemTest, BMS_GetLauncherAbilityByBundleNamePublic_ EXPECT_EQ(message, "Success") << "install fail!"; LauncherService launcherservice; - ErrCode result = launcherservice.GetLauncherAbilityByBundleNamePublic( + ErrCode result = launcherservice.GetLauncherAbilityInfoSync( bundleName, USERID, launcherAbilityInfos); EXPECT_EQ(result, ERR_OK); Uninstall(bundleName, message); @@ -977,31 +977,31 @@ HWTEST_F(BmsLauncherServiceSystemTest, BMS_GetLauncherAbilityByBundleNamePublic_ } /** - * @tc.number: BMS_GetLauncherAbilityByBundleNamePublic_0200 + * @tc.number: BMS_GetLauncherAbilityInfoSync_0200 * @tc.name: test GetAbilityInfo by LauncherService * @tc.desc: 1.install a low version hap * 2.install a high version hap * 3.get the application info of the high version hap by bundleName */ -HWTEST_F(BmsLauncherServiceSystemTest, BMS_GetLauncherAbilityByBundleNamePublic_0200, Function | MediumTest | Level1) +HWTEST_F(BmsLauncherServiceSystemTest, BMS_GetLauncherAbilityInfoSync_0200, Function | MediumTest | Level1) { std::vector launcherAbilityInfos; LauncherService launcherservice; - ErrCode result = launcherservice.GetLauncherAbilityByBundleNamePublic( + ErrCode result = launcherservice.GetLauncherAbilityInfoSync( "", USERID, launcherAbilityInfos); EXPECT_NE(result, ERR_OK); } /** - * @tc.number: BMS_GetLauncherAbilityByBundleNamePublic_0300 + * @tc.number: BMS_GetLauncherAbilityInfoSync_0300 * @tc.name: test GetAbilityInfo by LauncherService * @tc.desc: 1.install a low version hap * 2.install a high version hap * 3.get the application info of the high version hap by bundleName with invalid userId */ -HWTEST_F(BmsLauncherServiceSystemTest, BMS_GetLauncherAbilityByBundleNamePublic_0300, Function | MediumTest | Level1) +HWTEST_F(BmsLauncherServiceSystemTest, BMS_GetLauncherAbilityInfoSync_0300, Function | MediumTest | Level1) { - GTEST_LOG_(INFO) << "START BMS_GetLauncherAbilityByBundleNamePublic_0300"; + GTEST_LOG_(INFO) << "START BMS_GetLauncherAbilityInfoSync_0300"; std::string bundleName = TEST_BUNDLE_NAME; std::string bundleFilePath1 = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap"; std::vector launcherAbilityInfos; @@ -1011,7 +1011,7 @@ HWTEST_F(BmsLauncherServiceSystemTest, BMS_GetLauncherAbilityByBundleNamePublic_ EXPECT_EQ(message, "Success") << "install fail!"; LauncherService launcherservice; - ErrCode result = launcherservice.GetLauncherAbilityByBundleNamePublic( + ErrCode result = launcherservice.GetLauncherAbilityInfoSync( bundleName, Constants::INVALID_USERID, launcherAbilityInfos); EXPECT_NE(result, ERR_OK); Uninstall(bundleName, message);