!7056 修改verifyabc为系统接口

Merge pull request !7056 from amao/dfx
This commit is contained in:
openharmony_ci 2024-09-23 09:37:15 +00:00 committed by Gitee
commit d0f32a5f52
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 16 additions and 6 deletions

View File

@ -414,11 +414,11 @@ int32_t BundlePermissionMgr::GetHapApiVersion()
LOG_E(BMS_TAG_DEFAULT, "getApplicationInfo failed");
return Constants::INVALID_API_VERSION;
}
auto appApiVersion = applicationInfo.apiTargetVersion;
auto appApiVersion = applicationInfo.apiTargetVersion % BASE_API_VERSION;
LOG_D(BMS_TAG_DEFAULT, "appApiVersion is %{public}d", appApiVersion);
auto systemApiVersion = GetSdkApiVersion();
// api version is the minimum value of {appApiVersion, systemApiVersion}
return (systemApiVersion < appApiVersion ? systemApiVersion :appApiVersion) % BASE_API_VERSION;
return systemApiVersion < appApiVersion ? systemApiVersion :appApiVersion;
}
// if the api has been system api since it is published, then beginSystemApiVersion can be omitted

View File

@ -144,8 +144,13 @@ VerifyManagerHostImpl::~VerifyManagerHostImpl()
ErrCode VerifyManagerHostImpl::Verify(const std::vector<std::string> &abcPaths)
{
if (!BundlePermissionMgr::VerifySystemApp(ServiceConstants::API_VERSION_TWELVE) ||
!BundlePermissionMgr::VerifyCallingPermissionForAll(Constants::PERMISSION_RUN_DYN_CODE)) {
if (!BundlePermissionMgr::IsSystemApp() &&
!BundlePermissionMgr::VerifyCallingBundleSdkVersion(ServiceConstants::API_VERSION_TWELVE)) {
APP_LOGE("non-system app calling system api");
return ERR_BUNDLE_MANAGER_SYSTEM_API_DENIED;
}
if (!BundlePermissionMgr::VerifyCallingPermissionForAll(Constants::PERMISSION_RUN_DYN_CODE)) {
APP_LOGE("verify permission failed");
return ERR_BUNDLE_MANAGER_VERIFY_PERMISSION_DENIED;
}
@ -483,8 +488,13 @@ void VerifyManagerHostImpl::Rollback(const std::vector<std::string> &paths)
ErrCode VerifyManagerHostImpl::DeleteAbc(const std::string &path)
{
if (!BundlePermissionMgr::VerifySystemApp(ServiceConstants::API_VERSION_TWELVE) ||
!BundlePermissionMgr::VerifyCallingPermissionForAll(Constants::PERMISSION_RUN_DYN_CODE)) {
if (!BundlePermissionMgr::IsSystemApp() &&
!BundlePermissionMgr::VerifyCallingBundleSdkVersion(ServiceConstants::API_VERSION_TWELVE)) {
APP_LOGE("non-system app calling system api");
return ERR_BUNDLE_MANAGER_SYSTEM_API_DENIED;
}
if (!BundlePermissionMgr::VerifyCallingPermissionForAll(Constants::PERMISSION_RUN_DYN_CODE)) {
APP_LOGE("DeleteAbc failed due to permission denied");
return ERR_BUNDLE_MANAGER_VERIFY_PERMISSION_DENIED;
}