!7350 fix: checksyscap

Merge pull request !7350 from zhrenqiang/syscap
This commit is contained in:
openharmony_ci 2024-11-06 08:31:05 +00:00 committed by Gitee
commit a4dbbb32db
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 14 additions and 6 deletions

View File

@ -3079,9 +3079,9 @@ bool BMSEventHandler::CheckAndParseHapFiles(
ret = bundleInstallChecker->CheckSysCap(realPaths);
if (ret != ERR_OK) {
LOG_E(BMS_TAG_DEFAULT, "hap(%{public}s) syscap check failed", hapFilePath.c_str());
return false;
LOG_I(BMS_TAG_DEFAULT, "hap(%{public}s) syscap check failed", hapFilePath.c_str());
}
bool isSysCapValid = (ret == ERR_OK);
std::vector<Security::Verify::HapVerifyResult> hapVerifyResults;
ret = bundleInstallChecker->CheckMultipleHapsSignInfo(realPaths, hapVerifyResults);
@ -3103,6 +3103,14 @@ bool BMSEventHandler::CheckAndParseHapFiles(
return false;
}
if (!isSysCapValid) {
ret = bundleInstallChecker->CheckDeviceType(infos);
if (ret != ERR_OK) {
LOG_E(BMS_TAG_INSTALLER, "CheckDeviceType failed due to errorCode : %{public}d", ret);
return false;
}
}
ret = bundleInstallChecker->CheckHspInstallCondition(hapVerifyResults);
if (ret != ERR_OK) {
LOG_E(BMS_TAG_DEFAULT, "CheckHspInstallCondition failed %{public}d", ret);

View File

@ -181,8 +181,8 @@ ErrCode BundleParser::ParseSysCap(const std::string &pathName, std::vector<std::
}
if (!bundleExtractor.HasEntry(SYSCAP_NAME)) {
APP_LOGD("Rpcid.sc is not exist, and do not need verification sysCaps");
return ERR_OK;
APP_LOGI("Rpcid.sc is not exist, and do not need verification sysCaps");
return ERR_APPEXECFWK_PARSE_RPCID_FAILED;
}
std::stringstream rpcidStream;

View File

@ -511,7 +511,7 @@ HWTEST_F(BmsBundleInstallerTest, ThirdPartyInstall_0100, Function | SmallTest |
StopInstalldService();
std::string bundleFile = RESOURCE_ROOT_PATH + TYPE_BUNDLE;
auto result = InstallThirdPartyBundle(bundleFile);
EXPECT_EQ(result, ERR_APPEXECFWK_INSTALLD_GET_PROXY_ERROR);
EXPECT_EQ(result, ERR_APPEXECFWK_INSTALL_SYSCAP_FAILED_AND_DEVICE_TYPE_ERROR);
}
/**
@ -3066,7 +3066,7 @@ HWTEST_F(BmsBundleInstallerTest, InstallChecker_0100, Function | SmallTest | Lev
bundlePaths.push_back(bundlePath);
BundleInstallChecker installChecker;
auto ret = installChecker.CheckSysCap(bundlePaths);
EXPECT_EQ(ret, ERR_OK);
EXPECT_EQ(ret, ERR_APPEXECFWK_PARSE_RPCID_FAILED);
UnInstallBundle(BUNDLE_BACKUP_NAME);
}