mirror of
https://gitee.com/openharmony/bundlemanager_bundle_framework
synced 2024-11-23 15:20:24 +00:00
!5960 modification of return value as aot compiler fail
Merge pull request !5960 from ChenYC009/compile_dev
This commit is contained in:
commit
aec3786a8b
@ -233,6 +233,7 @@ enum {
|
||||
ERR_APPEXECFWK_AOT_ARGS_EMPTY = 8519929,
|
||||
ERR_APPEXECFWK_INSTALLD_GENERATE_KEY_FAILED = 8519930,
|
||||
ERR_APPEXECFWK_INSTALLD_DELETE_KEY_FAILED = 8519931,
|
||||
ERR_APPEXECFWK_INSTALLD_SIGN_AOT_FAILED = 8519932,
|
||||
|
||||
ERR_APPEXECFWK_RECOVER_GET_BUNDLEPATH_ERROR = APPEXECFWK_BUNDLEMGR_ERR_OFFSET + 0x0201, // 8520193
|
||||
ERR_APPEXECFWK_RECOVER_INVALID_BUNDLE_NAME = 8520194,
|
||||
|
@ -802,8 +802,8 @@ public:
|
||||
* @param isAllBundle Does it represent all bundlenames.
|
||||
* @return Returns true if the compile result is successfully obtained; returns false otherwise.
|
||||
*/
|
||||
virtual ErrCode CompileProcessAOT(
|
||||
const std::string &bundleName, const std::string &compileMode, bool isAllBundle)
|
||||
virtual ErrCode CompileProcessAOT(const std::string &bundleName, const std::string &compileMode,
|
||||
bool isAllBundle, std::vector<std::string> &compileResults)
|
||||
{
|
||||
return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR;
|
||||
}
|
||||
|
@ -570,8 +570,8 @@ public:
|
||||
* @param isAllBundle Does it represent all bundlenames.
|
||||
* @return Returns result of the operation.
|
||||
*/
|
||||
virtual ErrCode CompileProcessAOT(
|
||||
const std::string &bundleName, const std::string &compileMode, bool isAllBundle) override;
|
||||
virtual ErrCode CompileProcessAOT(const std::string &bundleName, const std::string &compileMode,
|
||||
bool isAllBundle, std::vector<std::string> &compileResults) override;
|
||||
/**
|
||||
* @brief Reset the bundle informations with specific flags through the proxy object.
|
||||
* @param bundleName Indicates the bundle name if needed.
|
||||
|
@ -1557,14 +1557,21 @@ ErrCode BundleMgrHost::HandleCompileProcessAOT(MessageParcel &data, MessageParce
|
||||
std::string bundleName = data.ReadString();
|
||||
std::string compileMode = data.ReadString();
|
||||
bool isAllBundle = data.ReadBool();
|
||||
std::vector<std::string> compileResults;
|
||||
|
||||
APP_LOGI("compile info name %{public}s", bundleName.c_str());
|
||||
ErrCode ret = CompileProcessAOT(bundleName, compileMode, isAllBundle);
|
||||
ErrCode ret = CompileProcessAOT(bundleName, compileMode, isAllBundle, compileResults);
|
||||
APP_LOGI("ret is %{public}d", ret);
|
||||
if (!reply.WriteInt32(ret)) {
|
||||
APP_LOGE("write failed");
|
||||
return ERR_APPEXECFWK_PARCEL_ERROR;
|
||||
}
|
||||
if (ret != ERR_OK) {
|
||||
if (!reply.WriteStringVector(compileResults)) {
|
||||
APP_LOGE("write compile process AOT results failed");
|
||||
return ERR_APPEXECFWK_PARCEL_ERROR;
|
||||
}
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
|
@ -4723,8 +4723,8 @@ ErrCode BundleMgrProxy::InnerGetBigString(MessageParcel &reply, std::string &res
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
ErrCode BundleMgrProxy::CompileProcessAOT(
|
||||
const std::string &bundleName, const std::string &compileMode, bool isAllBundle)
|
||||
ErrCode BundleMgrProxy::CompileProcessAOT(const std::string &bundleName, const std::string &compileMode,
|
||||
bool isAllBundle, std::vector<std::string> &compileResults)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
|
||||
APP_LOGD("begin to compile");
|
||||
@ -4751,7 +4751,14 @@ ErrCode BundleMgrProxy::CompileProcessAOT(
|
||||
APP_LOGE("fail to compile from server");
|
||||
return ERR_APPEXECFWK_PARCEL_ERROR;
|
||||
}
|
||||
return ERR_OK;
|
||||
ErrCode ret = reply.ReadInt32();
|
||||
if (ret != ERR_OK) {
|
||||
if (!reply.ReadStringVector(&compileResults)) {
|
||||
APP_LOGE("fail to get compile results from reply");
|
||||
return ERR_APPEXECFWK_PARCEL_ERROR;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
ErrCode BundleMgrProxy::CompileReset(const std::string &bundleName, bool isAllBundle)
|
||||
|
@ -36,7 +36,8 @@ public:
|
||||
void HandleInstall(const std::unordered_map<std::string, InnerBundleInfo> &infos) const;
|
||||
void HandleOTA();
|
||||
void HandleIdle() const;
|
||||
void HandleCompile(const std::string &bundleName, const std::string &compileMode, bool isAllBundle) const;
|
||||
ErrCode HandleCompile(const std::string &bundleName, const std::string &compileMode, bool isAllBundle,
|
||||
std::vector<std::string> &compileResults) const;
|
||||
void HandleResetAOT(const std::string &bundleName, bool isAllBundle) const;
|
||||
ErrCode HandleCopyAp(const std::string &bundleName, bool isAllBundle, std::vector<std::string> &results) const;
|
||||
private:
|
||||
@ -57,6 +58,10 @@ private:
|
||||
const InnerBundleInfo &info, const std::string &moduleName, const std::string &compileMode) const;
|
||||
EventInfo HandleCompileWithBundle(const std::string &bundleName, const std::string &compileMode,
|
||||
std::shared_ptr<BundleDataMgr> dataMgr) const;
|
||||
ErrCode HandleCompileBundles(const std::vector<std::string> &bundleNames, const std::string &compileMode,
|
||||
std::shared_ptr<BundleDataMgr> &dataMgr, std::vector<std::string> &compileResults) const;
|
||||
ErrCode HandleCompileModules(const std::vector<std::string> &moduleNames, const std::string &compileMode,
|
||||
InnerBundleInfo &info, std::string &compileResult) const;
|
||||
void ClearArkCacheDir() const;
|
||||
void ResetAOTFlags() const;
|
||||
void HandleIdleWithSingleHap(
|
||||
|
@ -550,8 +550,8 @@ public:
|
||||
* @param isAllBundle Does it represent all bundlenames.
|
||||
* @return Returns true if the compile result is successfully obtained; returns false otherwise.
|
||||
*/
|
||||
virtual ErrCode CompileProcessAOT(
|
||||
const std::string &bundleName, const std::string &compileMode, bool isAllBundle) override;
|
||||
virtual ErrCode CompileProcessAOT(const std::string &bundleName, const std::string &compileMode,
|
||||
bool isAllBundle, std::vector<std::string> &compileResults) override;
|
||||
/**
|
||||
* @brief Compile the bundle informations with specific flags.
|
||||
* @param bundleName Indicates the bundle name if needed.
|
||||
|
@ -58,6 +58,7 @@ constexpr const char* APP_IDENTIFIER = "appIdentifier";
|
||||
constexpr const char* IS_ENCRYPTED_BUNDLE = "isEncryptedBundle";
|
||||
constexpr const char* IS_SCREEN_OFF = "isScreenOff";
|
||||
constexpr const char* PGO_DIR = "pgoDir";
|
||||
const int32_t ERR_AOT_COMPILER_SIGN_FAILED = 10004;
|
||||
}
|
||||
|
||||
AOTExecutor& AOTExecutor::GetInstance()
|
||||
@ -194,12 +195,12 @@ ErrCode AOTExecutor::EnforceCodeSign(const AOTArgs &aotArgs, const std::vector<i
|
||||
Security::CodeSign::ByteBuffer sigBuffer;
|
||||
if (!sigBuffer.CopyFrom(byteData.data(), byteSize)) {
|
||||
APP_LOGE("fail to receive code signature ByteBuffer");
|
||||
return ERR_APPEXECFWK_INSTALLD_AOT_EXECUTE_FAILED;
|
||||
return ERR_APPEXECFWK_INSTALLD_SIGN_AOT_FAILED;
|
||||
}
|
||||
if (Security::CodeSign::CodeSignUtils::EnforceCodeSignForFile(aotArgs.anFileName, sigBuffer)
|
||||
!= CommonErrCode::CS_SUCCESS) {
|
||||
APP_LOGE("fail to enable code signature for the aot file");
|
||||
return ERR_APPEXECFWK_INSTALLD_AOT_EXECUTE_FAILED;
|
||||
return ERR_APPEXECFWK_INSTALLD_SIGN_AOT_FAILED;
|
||||
}
|
||||
APP_LOGI("sign aot file success");
|
||||
return ERR_OK;
|
||||
@ -223,6 +224,10 @@ ErrCode AOTExecutor::StartAOTCompiler(const AOTArgs &aotArgs, std::vector<int16_
|
||||
}
|
||||
APP_LOGI("start to aot compiler");
|
||||
ret = ArkCompiler::AotCompilerClient::GetInstance().AotCompiler(argsMap, sigData);
|
||||
if (ret == ERR_AOT_COMPILER_SIGN_FAILED) {
|
||||
APP_LOGE("aot compiler local signature fail");
|
||||
return ERR_APPEXECFWK_INSTALLD_SIGN_AOT_FAILED;
|
||||
}
|
||||
if (ret != ERR_OK) {
|
||||
APP_LOGE("aot compiler fail");
|
||||
return ERR_APPEXECFWK_INSTALLD_AOT_EXECUTE_FAILED;
|
||||
|
@ -707,26 +707,35 @@ void AOTHandler::HandleIdle() const
|
||||
APP_LOGI("HandleIdle end");
|
||||
}
|
||||
|
||||
void AOTHandler::HandleCompile(const std::string &bundleName, const std::string &compileMode, bool isAllBundle) const
|
||||
ErrCode AOTHandler::HandleCompile(const std::string &bundleName, const std::string &compileMode, bool isAllBundle,
|
||||
std::vector<std::string> &compileResults) const
|
||||
{
|
||||
APP_LOGI("HandleCompile begin");
|
||||
std::unique_lock<std::mutex> lock(compileMutex_, std::defer_lock);
|
||||
if (!lock.try_lock()) {
|
||||
APP_LOGI("compile task is running, skip %{public}s", bundleName.c_str());
|
||||
return;
|
||||
std::string compileResult = "info: compile task is running, skip.";
|
||||
compileResults.emplace_back(compileResult);
|
||||
return ERR_APPEXECFWK_INSTALLD_AOT_EXECUTE_FAILED;
|
||||
}
|
||||
if (!IsSupportARM64()) {
|
||||
APP_LOGI("current device doesn't support arm64, no need to AOT");
|
||||
return;
|
||||
std::string compileResult = "info: current device doesn't support arm64, no need to AOT.";
|
||||
compileResults.emplace_back(compileResult);
|
||||
return ERR_APPEXECFWK_INSTALLD_AOT_EXECUTE_FAILED;
|
||||
}
|
||||
if (compileMode == COMPILE_NONE) {
|
||||
APP_LOGI("%{public}s = none, no need to AOT", IDLE_COMPILE_MODE);
|
||||
return;
|
||||
std::string compileResult = "info: persist.bm.idle.arkopt = none, no need to AOT.";
|
||||
compileResults.emplace_back(compileResult);
|
||||
return ERR_APPEXECFWK_INSTALLD_AOT_EXECUTE_FAILED;
|
||||
}
|
||||
auto dataMgr = DelayedSingleton<BundleMgrService>::GetInstance()->GetDataMgr();
|
||||
if (!dataMgr) {
|
||||
APP_LOGE("dataMgr is null");
|
||||
return;
|
||||
std::string compileResult = "error: dataMgr is null, compile fail.";
|
||||
compileResults.emplace_back(compileResult);
|
||||
return ERR_APPEXECFWK_INSTALLD_AOT_EXECUTE_FAILED;
|
||||
}
|
||||
std::vector<std::string> bundleNames;
|
||||
if (isAllBundle) {
|
||||
@ -734,25 +743,78 @@ void AOTHandler::HandleCompile(const std::string &bundleName, const std::string
|
||||
} else {
|
||||
bundleNames = {bundleName};
|
||||
}
|
||||
std::for_each(bundleNames.cbegin(), bundleNames.cend(), [this, dataMgr, &compileMode](const auto &bundleToCompile) {
|
||||
ErrCode ret = HandleCompileBundles(bundleNames, compileMode, dataMgr, compileResults);
|
||||
if (ret == ERR_OK) {
|
||||
compileResults.clear();
|
||||
}
|
||||
APP_LOGI("HandleCompile end");
|
||||
return ret;
|
||||
}
|
||||
|
||||
ErrCode AOTHandler::HandleCompileBundles(const std::vector<std::string> &bundleNames, const std::string &compileMode,
|
||||
std::shared_ptr<BundleDataMgr> &dataMgr, std::vector<std::string> &compileResults) const
|
||||
{
|
||||
ErrCode ret = ERR_OK;
|
||||
std::for_each(bundleNames.cbegin(), bundleNames.cend(),
|
||||
[this, dataMgr, &compileMode, &ret, &compileResults](const auto &bundleToCompile) {
|
||||
APP_LOGD("HandleCompile bundleToCompile : %{public}s", bundleToCompile.c_str());
|
||||
InnerBundleInfo info;
|
||||
if (!dataMgr->QueryInnerBundleInfo(bundleToCompile, info)) {
|
||||
APP_LOGE("QueryInnerBundleInfo failed. bundleToCompile: %{public}s", bundleToCompile.c_str());
|
||||
std::string compileResult = bundleToCompile + ": QueryInnerBundleInfo failed.";
|
||||
compileResults.emplace_back(compileResult);
|
||||
ret = ERR_APPEXECFWK_INSTALLD_AOT_EXECUTE_FAILED;
|
||||
return;
|
||||
}
|
||||
if (!info.GetIsNewVersion()) {
|
||||
APP_LOGD("not stage model, no need to AOT");
|
||||
std::string compileResult = bundleToCompile + ": not stage model, no need to AOT.";
|
||||
compileResults.emplace_back(compileResult);
|
||||
ret = ERR_APPEXECFWK_INSTALLD_AOT_EXECUTE_FAILED;
|
||||
return;
|
||||
}
|
||||
std::vector<std::string> moduleNames;
|
||||
info.GetModuleNames(moduleNames);
|
||||
std::for_each(moduleNames.cbegin(), moduleNames.cend(),
|
||||
[this, &info, &compileMode](const auto &moduleName) {
|
||||
(void)HandleCompileWithSingleHap(info, moduleName, compileMode);
|
||||
});
|
||||
std::string compileResult = "";
|
||||
if (HandleCompileModules(moduleNames, compileMode, info, compileResult) == ERR_OK) {
|
||||
compileResult = bundleToCompile + ": compile success.";
|
||||
} else {
|
||||
compileResult = bundleToCompile + ":" + compileResult;
|
||||
ret = ERR_APPEXECFWK_INSTALLD_AOT_EXECUTE_FAILED;
|
||||
}
|
||||
compileResults.emplace_back(compileResult);
|
||||
});
|
||||
APP_LOGI("HandleCompile end");
|
||||
return ret;
|
||||
}
|
||||
|
||||
ErrCode AOTHandler::HandleCompileModules(const std::vector<std::string> &moduleNames, const std::string &compileMode,
|
||||
InnerBundleInfo &info, std::string &compileResult) const
|
||||
{
|
||||
ErrCode ret = ERR_OK;
|
||||
std::for_each(moduleNames.cbegin(), moduleNames.cend(),
|
||||
[this, &info, &compileMode, &ret, &compileResult](const auto &moduleName) {
|
||||
ErrCode errCode = HandleCompileWithSingleHap(info, moduleName, compileMode);
|
||||
switch (errCode) {
|
||||
case ERR_OK:
|
||||
break;
|
||||
case ERR_APPEXECFWK_INSTALLD_AOT_EXECUTE_FAILED:
|
||||
compileResult += " " + moduleName + ":compile-fail";
|
||||
break;
|
||||
case ERR_APPEXECFWK_INSTALLD_SIGN_AOT_FAILED:
|
||||
compileResult += " " + moduleName + ":signature-fail";
|
||||
break;
|
||||
case ERR_APPEXECFWK_AOT_ARGS_EMPTY:
|
||||
compileResult += " " + moduleName + ":args-empty";
|
||||
break;
|
||||
default:
|
||||
compileResult += " " + moduleName + ":other-fail";
|
||||
break;
|
||||
}
|
||||
if (errCode != ERR_OK) {
|
||||
ret = ERR_APPEXECFWK_INSTALLD_AOT_EXECUTE_FAILED;
|
||||
}
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
@ -1709,15 +1709,14 @@ bool BundleMgrHostImpl::UnregisterBundleStatusCallback()
|
||||
return dataMgr->UnregisterBundleStatusCallback();
|
||||
}
|
||||
|
||||
ErrCode BundleMgrHostImpl::CompileProcessAOT(
|
||||
const std::string &bundleName, const std::string &compileMode, bool isAllBundle)
|
||||
ErrCode BundleMgrHostImpl::CompileProcessAOT(const std::string &bundleName, const std::string &compileMode,
|
||||
bool isAllBundle, std::vector<std::string> &compileResults)
|
||||
{
|
||||
if (!BundlePermissionMgr::VerifyCallingPermissionForAll(Constants::PERMISSION_GET_BUNDLE_INFO_PRIVILEGED)) {
|
||||
APP_LOGE("verify permission failed");
|
||||
return ERR_BUNDLE_MANAGER_PERMISSION_DENIED;
|
||||
}
|
||||
AOTHandler::GetInstance().HandleCompile(bundleName, compileMode, isAllBundle);
|
||||
return ERR_OK;
|
||||
return AOTHandler::GetInstance().HandleCompile(bundleName, compileMode, isAllBundle, compileResults);
|
||||
}
|
||||
|
||||
ErrCode BundleMgrHostImpl::CompileReset(const std::string &bundleName, bool isAllBundle)
|
||||
|
@ -575,15 +575,16 @@ HWTEST_F(BmsAOTMgrTest, AOTHandler_1100, Function | SmallTest | Level0)
|
||||
HWTEST_F(BmsAOTMgrTest, AOTHandler_1200, Function | SmallTest | Level0)
|
||||
{
|
||||
std::string bundleName = "";
|
||||
std::vector<std::string> results;
|
||||
ClearDataMgr();
|
||||
AOTHandler::GetInstance().HandleCompile(bundleName, COMPILE_NONE, true);
|
||||
AOTHandler::GetInstance().HandleCompile(bundleName, COMPILE_NONE, true, results);
|
||||
EXPECT_EQ(bundleName, "");
|
||||
ResetDataMgr();
|
||||
|
||||
AOTHandler::GetInstance().HandleCompile(bundleName, Constants::COMPILE_PARTIAL, true);
|
||||
AOTHandler::GetInstance().HandleCompile(bundleName, Constants::COMPILE_PARTIAL, true, results);
|
||||
EXPECT_EQ(bundleName, "");
|
||||
|
||||
AOTHandler::GetInstance().HandleCompile(bundleName, Constants::COMPILE_PARTIAL, false);
|
||||
AOTHandler::GetInstance().HandleCompile(bundleName, Constants::COMPILE_PARTIAL, false, results);
|
||||
EXPECT_EQ(bundleName, "");
|
||||
}
|
||||
|
||||
|
@ -1902,7 +1902,8 @@ HWTEST_F(BmsInstallSystemTest, CompileProcessAOT_0100, Function | SmallTest | Le
|
||||
APP_LOGE("bundle mgr proxy is nullptr.");
|
||||
EXPECT_EQ(bundleMgrProxy, nullptr);
|
||||
}
|
||||
ErrCode ret = bundleMgrProxy->CompileProcessAOT("", "", false);
|
||||
std::vector<std::string> results;
|
||||
ErrCode ret = bundleMgrProxy->CompileProcessAOT("", "", false, results);
|
||||
EXPECT_EQ(ret, ERR_OK);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user