mirror of
https://gitee.com/openharmony/bundlemanager_bundle_framework
synced 2024-11-23 07:09:53 +00:00
!4984 bm工具适配禁用ability的资源信息
Merge pull request !4984 from wangtiantian/resource_bm
This commit is contained in:
commit
79444cebc8
@ -847,6 +847,7 @@ public:
|
|||||||
std::string &profile) const;
|
std::string &profile) const;
|
||||||
bool GetFingerprints(const std::string &bundleName, std::vector<std::string> &fingerPrints) const;
|
bool GetFingerprints(const std::string &bundleName, std::vector<std::string> &fingerPrints) const;
|
||||||
ErrCode GetInnerBundleInfoByUid(const int uid, InnerBundleInfo &innerBundleInfo) const;
|
ErrCode GetInnerBundleInfoByUid(const int uid, InnerBundleInfo &innerBundleInfo) const;
|
||||||
|
std::string GetModuleNameByBundleAndAbility(const std::string& bundleName, const std::string& abilityName);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
|
@ -5733,5 +5733,27 @@ bool BundleDataMgr::IsUpdateInnerBundleInfoSatisified(const InnerBundleInfo &old
|
|||||||
{
|
{
|
||||||
return !oldInfo.HasEntry() || oldInfo.GetEntryInstallationFree() || newInfo.HasEntry();
|
return !oldInfo.HasEntry() || oldInfo.GetEntryInstallationFree() || newInfo.HasEntry();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string BundleDataMgr::GetModuleNameByBundleAndAbility(
|
||||||
|
const std::string& bundleName, const std::string& abilityName)
|
||||||
|
{
|
||||||
|
if (bundleName.empty() || abilityName.empty()) {
|
||||||
|
APP_LOGE("bundleName or abilityName is empty");
|
||||||
|
return std::string();
|
||||||
|
}
|
||||||
|
std::shared_lock<std::shared_mutex> lock(bundleInfoMutex_);
|
||||||
|
auto innerBundleInfo = bundleInfos_.find(bundleName);
|
||||||
|
if (innerBundleInfo == bundleInfos_.end()) {
|
||||||
|
APP_LOGE("can not find bundle %{public}s.", bundleName.c_str());
|
||||||
|
return std::string();
|
||||||
|
}
|
||||||
|
auto abilityInfo = innerBundleInfo->second.FindAbilityInfoV9(Constants::EMPTY_STRING, abilityName);
|
||||||
|
if (!abilityInfo) {
|
||||||
|
APP_LOGE("bundleName:%{public}s, abilityName:%{public}s can find moduleName",
|
||||||
|
bundleName.c_str(), abilityName.c_str());
|
||||||
|
return std::string();
|
||||||
|
}
|
||||||
|
return abilityInfo->moduleName;
|
||||||
|
}
|
||||||
} // namespace AppExecFwk
|
} // namespace AppExecFwk
|
||||||
} // namespace OHOS
|
} // namespace OHOS
|
||||||
|
@ -1640,10 +1640,7 @@ ErrCode BundleMgrHostImpl::SetAbilityEnabled(const AbilityInfo &abilityInfo, boo
|
|||||||
}
|
}
|
||||||
std::string moduleName = abilityInfo.moduleName;
|
std::string moduleName = abilityInfo.moduleName;
|
||||||
if (moduleName.empty()) {
|
if (moduleName.empty()) {
|
||||||
AbilityInfo info;
|
moduleName = dataMgr->GetModuleNameByBundleAndAbility(abilityInfo.bundleName, abilityInfo.name);
|
||||||
if (GetAbilityInfo(abilityInfo.bundleName, abilityInfo.name, info)) {
|
|
||||||
moduleName = info.moduleName;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
BundleResourceHelper::SetAbilityEnabled(abilityInfo.bundleName, moduleName, abilityInfo.name, isEnabled, userId);
|
BundleResourceHelper::SetAbilityEnabled(abilityInfo.bundleName, moduleName, abilityInfo.name, isEnabled, userId);
|
||||||
EventReport::SendComponentStateSysEvent(abilityInfo.bundleName, abilityInfo.name, userId, isEnabled, false);
|
EventReport::SendComponentStateSysEvent(abilityInfo.bundleName, abilityInfo.name, userId, isEnabled, false);
|
||||||
|
@ -118,10 +118,10 @@ bool BundleResourceCallback::OnBundleStatusChanged(
|
|||||||
APP_LOGE("bundleName is empty");
|
APP_LOGE("bundleName is empty");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (userId != Constants::START_USERID) {
|
if (userId != Constants::DEFAULT_USERID) {
|
||||||
int32_t currentUserId = AccountHelper::GetCurrentActiveUserId();
|
int32_t currentUserId = AccountHelper::GetCurrentActiveUserId();
|
||||||
if (currentUserId != userId) {
|
if ((currentUserId > 0) && (currentUserId != userId)) {
|
||||||
APP_LOGE("userId: %{public}d, currentUserId :%{public}d", userId, currentUserId);
|
APP_LOGE("userId: %{public}d, currentUserId :%{public}d not same", userId, currentUserId);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -154,11 +154,10 @@ bool BundleResourceCallback::OnAbilityStatusChanged(const std::string &bundleNam
|
|||||||
APP_LOGE("bundleName or moduleName or abilityName is empty");
|
APP_LOGE("bundleName or moduleName or abilityName is empty");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (userId != Constants::DEFAULT_USERID) {
|
||||||
if (userId != Constants::START_USERID) {
|
|
||||||
int32_t currentUserId = AccountHelper::GetCurrentActiveUserId();
|
int32_t currentUserId = AccountHelper::GetCurrentActiveUserId();
|
||||||
if (currentUserId != userId) {
|
if ((currentUserId > 0) && (currentUserId != userId)) {
|
||||||
APP_LOGE("wtt userId: %{public}d, currentUserId :%{public}d not same", userId, currentUserId);
|
APP_LOGE("userId: %{public}d, currentUserId :%{public}d not same", userId, currentUserId);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3681,6 +3681,33 @@ HWTEST_F(BmsBundleDataMgrTest, ExplicitQueryAbilityInfoV9_0300, Function | Small
|
|||||||
EXPECT_EQ(testRet, ERR_BUNDLE_MANAGER_ABILITY_NOT_EXIST);
|
EXPECT_EQ(testRet, ERR_BUNDLE_MANAGER_ABILITY_NOT_EXIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number: GetModuleNameByBundleAndAbility_0100
|
||||||
|
* @tc.name: GetModuleNameByBundleAndAbility
|
||||||
|
* @tc.desc: GetModuleNameByBundleAndAbility
|
||||||
|
*/
|
||||||
|
HWTEST_F(BmsBundleDataMgrTest, GetModuleNameByBundleAndAbility_0100, Function | SmallTest | Level0)
|
||||||
|
{
|
||||||
|
std::string moduleName = GetBundleDataMgr()->GetModuleNameByBundleAndAbility("", ABILITY_NAME_TEST);
|
||||||
|
EXPECT_TRUE(moduleName.empty());
|
||||||
|
|
||||||
|
moduleName = GetBundleDataMgr()->GetModuleNameByBundleAndAbility(BUNDLE_NAME_TEST, "");
|
||||||
|
EXPECT_TRUE(moduleName.empty());
|
||||||
|
|
||||||
|
moduleName = GetBundleDataMgr()->GetModuleNameByBundleAndAbility(BUNDLE_NAME_TEST, ABILITY_NAME_TEST);
|
||||||
|
EXPECT_TRUE(moduleName.empty());
|
||||||
|
|
||||||
|
MockInstallBundle(BUNDLE_NAME_TEST, MODULE_NAME_TEST, ABILITY_NAME_TEST);
|
||||||
|
|
||||||
|
moduleName = GetBundleDataMgr()->GetModuleNameByBundleAndAbility(BUNDLE_NAME_TEST, MODULE_NAME_TEST);
|
||||||
|
EXPECT_TRUE(moduleName.empty());
|
||||||
|
|
||||||
|
moduleName = GetBundleDataMgr()->GetModuleNameByBundleAndAbility(BUNDLE_NAME_TEST, ABILITY_NAME_TEST);
|
||||||
|
EXPECT_EQ(moduleName, MODULE_NAME_TEST);
|
||||||
|
|
||||||
|
MockUninstallBundle(BUNDLE_NAME_TEST);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @tc.number: FilterAbilityInfosByModuleName_0100
|
* @tc.number: FilterAbilityInfosByModuleName_0100
|
||||||
* @tc.name: test FilterAbilityInfosByModuleName
|
* @tc.name: test FilterAbilityInfosByModuleName
|
||||||
|
Loading…
Reference in New Issue
Block a user