车机BMS查询接口适配:QueryAbilityInfo

Signed-off-by: l30069879 <lijingjie4@h-partners.com>

AI[0%] Human Fixed[0%] Human[100%] AI Adopted[0%]
This commit is contained in:
l30069879
2026-07-29 23:32:18 +08:00
parent efeff9ad06
commit e9aa81ef85
6 changed files with 59 additions and 12 deletions
+2 -7
View File
@@ -41,6 +41,7 @@ declare_args() {
bundle_framework_form_dimension_3_3 = false
bundle_framework_bss_enable = false
bundle_framework_npapi_enable = false
bundle_framework_enable_clone_for_account = false
ability_runtime_enable = true
account_enable = true
@@ -66,7 +67,6 @@ declare_args() {
bundle_framework_app_fwk_update_enable = true
user_auth_framework_impl_enabled = true
api_metrics_enable = true
enable_clone_for_account = false
if (defined(global_parts_info) &&
!defined(global_parts_info.resourceschedule_device_usage_statistics)) {
@@ -204,11 +204,6 @@ declare_args() {
!defined(global_parts_info.hiviewdfx_api_metrics)) {
api_metrics_enable = false
}
if (defined(global_parts_info) &&
defined(global_parts_info.bundle_framework_enable_clone_for_account)) {
enable_clone_for_account = true
}
}
print("bundle_framework_power_mgr_enable = " +
@@ -240,4 +235,4 @@ print(
print(
"bundle_framework_npapi_enable = " + "$bundle_framework_npapi_enable")
print("bms_accesscontrol_sandbox_manager = " + "$bms_accesscontrol_sandbox_manager")
print("enable_clone_for_account = " + "$enable_clone_for_account")
print("bundle_framework_enable_clone_for_account = " + "$bundle_framework_enable_clone_for_account")
+1 -1
View File
@@ -605,7 +605,7 @@ ohos_shared_library("libbms") {
defines += [ "BMS_ACCESSCONTROL_SANDBOX_MANAGER" ]
}
if (enable_clone_for_account) {
if (bundle_framework_enable_clone_for_account) {
sources += [ "${services_path}/bundlemgr/src/clone/clone_for_account_util.cpp" ]
defines += [ "BMS_ENABLE_CLONE_FOR_ACCOUNT" ]
}
+42 -3
View File
@@ -1351,7 +1351,21 @@ bool BundleDataMgr::ExplicitQueryAbilityInfo(const Want &want, int32_t flags, in
" -u %{public}d", bundleName.c_str(), moduleName.c_str(), abilityName.c_str(), responseUserId);
return false;
}
return QueryAbilityInfoWithFlags(ability, flags, responseUserId, *innerBundleInfo, abilityInfo);
int32_t queryAppIndex = appIndex;
#ifdef BMS_ENABLE_CLONE_FOR_ACCOUNT
if (appIndex == Constants::MAIN_APP_INDEX &&
!(static_cast<uint32_t>(flags) & static_cast<uint32_t>(ApplicationFlag::GET_APPLICATION_INFO_WITH_DISABLE))) {
int32_t enableAppIndex = CloneForAccountUtil::GetEnabledCloneAppIndex(*innerBundleInfo, requestUserId);
if (enableAppIndex == Constants::ALL_CLONE_APP_INDEX) {
LOG_NOFUNC_W(BMS_TAG_QUERY, "car mode: all apps disabled, bundleName:%{public}s", bundleName.c_str());
return false;
}
queryAppIndex = enableAppIndex;
LOG_NOFUNC_D(BMS_TAG_QUERY, "car mode: use clone appIndex:%{public}d, bundleName:%{public}s",
queryAppIndex, bundleName.c_str());
}
#endif
return QueryAbilityInfoWithFlags(ability, flags, responseUserId, *innerBundleInfo, abilityInfo, queryAppIndex);
}
ErrCode BundleDataMgr::ExplicitQueryAbilityInfoV9(const Want &want, int32_t flags, int32_t userId,
@@ -1850,7 +1864,19 @@ bool BundleDataMgr::ImplicitQueryCurAbilityInfos(const Want &want, int32_t flags
int32_t responseUserId = innerBundleInfo->GetResponseUserId(userId);
std::vector<std::string> mimeTypes;
MimeTypeMgr::GetMimeTypeByUri(want.GetUriString(), mimeTypes);
GetMatchAbilityInfos(want, flags, *innerBundleInfo, responseUserId, abilityInfos, mimeTypes);
int32_t queryAppIndex = appIndex;
#ifdef BMS_ENABLE_CLONE_FOR_ACCOUNT
if (appIndex == Constants::MAIN_APP_INDEX &&
!(static_cast<uint32_t>(flags) & static_cast<uint32_t>(AbilityInfoFlag::GET_ABILITY_INFO_WITH_DISABLE))) {
int32_t enableAppIndex = CloneForAccountUtil::GetEnabledCloneAppIndex(*innerBundleInfo, userId);
if (enableAppIndex == Constants::ALL_CLONE_APP_INDEX) {
LOG_NOFUNC_W(BMS_TAG_QUERY, "car mode: all apps disabled, bundleName:%{public}s", bundleName.c_str());
return false;
}
queryAppIndex = enableAppIndex;
}
#endif
GetMatchAbilityInfos(want, flags, *innerBundleInfo, responseUserId, abilityInfos, mimeTypes, queryAppIndex);
FilterAbilityInfosByModuleName(want.GetElement().GetModuleName(), abilityInfos);
return true;
}
@@ -1987,7 +2013,20 @@ void BundleDataMgr::ImplicitQueryAllAbilityInfos(const Want &want, int32_t flags
innerBundleInfo.GetBundleName().c_str(), responseUserId);
continue;
}
GetMatchAbilityInfos(want, flags, innerBundleInfo, responseUserId, abilityInfos, mimeTypes);
int32_t queryAppIndex = 0;
#ifdef BMS_ENABLE_CLONE_FOR_ACCOUNT
if (!(static_cast<uint32_t>(flags) & static_cast<uint32_t>(ApplicationFlag::GET_APPLICATION_INFO_WITH_DISABLE))) {
int32_t enableAppIndex = CloneForAccountUtil::GetEnabledCloneAppIndex(innerBundleInfo, requestUserId);
if (enableAppIndex == Constants::ALL_CLONE_APP_INDEX) {
LOG_D(BMS_TAG_QUERY,
"ImplicitQueryAllAbilityInfos failed, bundleName:%{public}s, responseUserId:%{public}d",
innerBundleInfo.GetBundleName().c_str(), responseUserId);
continue;
}
queryAppIndex = enableAppIndex;
}
#endif
GetMatchAbilityInfos(want, flags, innerBundleInfo, responseUserId, abilityInfos, mimeTypes, queryAppIndex);
}
} else {
// query from sandbox manager for sandbox bundle
@@ -407,6 +407,11 @@ ohos_unittest("BmsBundleKitServiceTest") {
]
defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ]
}
if (bundle_framework_enable_clone_for_account) {
sources += [ "${services_path}/bundlemgr/src/clone/clone_for_account_util.cpp" ]
defines += [ "BMS_ENABLE_CLONE_FOR_ACCOUNT" ]
}
}
ohos_unittest("BmsBundleKitServiceTwoTest") {
@@ -3277,7 +3277,11 @@ HWTEST_F(BmsBundleKitServiceTest, QueryAbilityInfos_1200, Function | SmallTest |
result.clear();
testRet = GetBundleDataMgr()->QueryAbilityInfos(want, flags, DEFAULT_USER_ID_TEST, result);
EXPECT_TRUE(testRet);
#ifndef BMS_ENABLE_CLONE_FOR_ACCOUNT
EXPECT_EQ(result.size(), 3);
#else
EXPECT_GE(result.size(), 3);
#endif
result.clear();
flags = static_cast<int32_t>(ApplicationFlag::GET_APPLICATION_INFO_WITH_DISABLE);
@@ -3330,7 +3334,11 @@ HWTEST_F(BmsBundleKitServiceTest, QueryAbilityInfos_1300, Function | SmallTest |
count++;
}
}
#ifndef BMS_ENABLE_CLONE_FOR_ACCOUNT
EXPECT_EQ(count, 3);
#else
EXPECT_GE(count, 3);
#endif
result.clear();
flags = GET_ABILITY_INFO_WITH_DISABLE;
@@ -183,7 +183,7 @@ ohos_unittest("BmsDataMgrTest") {
defines += [ "BUNDLE_FRAMEWORK_OVERLAY_INSTALLATION" ]
}
if (enable_clone_for_account) {
if (bundle_framework_enable_clone_for_account) {
sources += [ "${services_path}/bundlemgr/src/clone/clone_for_account_util.cpp" ]
defines += [ "BMS_ENABLE_CLONE_FOR_ACCOUNT" ]
}