From 2b5a747a8605a0aaf400a5a1aa34a97f944ca8ee Mon Sep 17 00:00:00 2001 From: wangdengjia Date: Fri, 2 Jul 2021 16:24:42 +0800 Subject: [PATCH] IssueNo:#I3O061 Description:Add transform bytecode. Sig:startup Feature or Bugfix:Feature Binary Source:No --- .../bundlemgr_lite/include/gt_bundle_installer.h | 1 + .../bundlemgr_lite/src/gt_bundle_installer.cpp | 9 +++++++-- .../src/gt_bundle_manager_service.cpp | 15 +++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/services/bundlemgr_lite/include/gt_bundle_installer.h b/services/bundlemgr_lite/include/gt_bundle_installer.h index 9e3a750..ed558e5 100755 --- a/services/bundlemgr_lite/include/gt_bundle_installer.h +++ b/services/bundlemgr_lite/include/gt_bundle_installer.h @@ -19,6 +19,7 @@ #ifdef __cplusplus extern "C" { #endif +#include "generate-bytecode.h" #ifdef __cplusplus } #endif diff --git a/services/bundlemgr_lite/src/gt_bundle_installer.cpp b/services/bundlemgr_lite/src/gt_bundle_installer.cpp index 3815bf3..69eeefc 100755 --- a/services/bundlemgr_lite/src/gt_bundle_installer.cpp +++ b/services/bundlemgr_lite/src/gt_bundle_installer.cpp @@ -18,7 +18,6 @@ #ifdef __cplusplus extern "C" { -#include "generate-bytecode.h" #endif #ifdef __cplusplus } @@ -235,12 +234,12 @@ uint8_t GtBundleInstaller::ProcessBundleInstall(const char *path, const char *ra BundleInfo *bundleInfo = nullptr; (void) GtManagerService::GetInstance().ReportInstallCallback(OPERATION_DOING, 0, BMS_FIRST_FINISHED_PROCESS, installerCallback); uint8_t errorCode = PreCheckBundle(path, fp, signatureInfo, fileSize, bundleStyle); + (void) GtManagerService::GetInstance().ReportInstallCallback(OPERATION_DOING, 0, BMS_SECOND_FINISHED_PROCESS, installerCallback); CHECK_PRO_RESULT(errorCode, fp, permissions, bundleInfo, signatureInfo); // parse HarmoyProfile.json, get permissions and bundleInfo errorCode = GtBundleParser::ParseHapProfile(fp, fileSize, permissions, bundleRes, &bundleInfo); CHECK_PRO_RESULT(errorCode, fp, permissions, bundleInfo, signatureInfo); SetCurrentBundle(bundleInfo->bundleName); - (void) GtManagerService::GetInstance().ReportInstallCallback(OPERATION_DOING, 0, BMS_SECOND_FINISHED_PROCESS, installerCallback); // terminate current runing app uint32_t labelId = (bundleRes.abilityRes != nullptr) ? bundleRes.abilityRes->labelId : 0; uint32_t iconId = (bundleRes.abilityRes != nullptr) ? bundleRes.abilityRes->iconId : 0; @@ -471,6 +470,12 @@ uint8_t GtBundleInstaller::TransformJsToBc(const char *codePath, InstallRecord & if (jsPath == nullptr) { return ERR_APPEXECFWK_INSTALL_FAILED_INTERNAL_ERROR; } + EXECRES result = walk_directory(jsPath); + HILOG_INFO(HILOG_MODULE_AAFWK, "[BMS] transform js to bc when install, result is %d", result); + if (result != EXCE_ACE_JERRY_EXEC_OK) { + AdapterFree(jsPath); + return ERR_APPEXECFWK_INSTALL_FAILED_TRANSFORM_BC_FILE_ERROR; + } AdapterFree(jsPath); #ifdef BC_TRANS_ENABLE record.transformResult = 0; diff --git a/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp b/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp index 6f4e0d7..6c655ca 100755 --- a/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp +++ b/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp @@ -28,6 +28,7 @@ #include "gt_bundle_extractor.h" #include "gt_bundle_parser.h" #include "gt_extractor_util.h" +#include "jerryscript_adapter.h" #include "los_tick.h" #include "stdio.h" #include "sys/stat.h" @@ -335,6 +336,12 @@ void GtManagerService::ClearSystemBundleInstallMsg() void GtManagerService::ScanPackages() { + JerryBmsPsRamMemInit(); + bms_task_context_init(); + jsEngineVer_ = get_jerry_version_no(); + if (jsEngineVer_ == nullptr) { + HILOG_WARN(HILOG_MODULE_AAFWK, "[BMS] get jsEngine version fail when restart!"); + } if (!BundleUtil::IsDir(JSON_PATH_NO_SLASH_END)) { BundleUtil::MkDirs(JSON_PATH_NO_SLASH_END); InstallAllSystemBundle(); @@ -742,6 +749,14 @@ void GtManagerService::TransformJsToBc(const char *codePath, const char *bundleJ return; } + EXECRES result = walk_directory(jsPath); + HILOG_INFO(HILOG_MODULE_AAFWK, "[BMS] transform js to bc, result is %d", result); + if (result != EXCE_ACE_JERRY_EXEC_OK) { + result = walk_del_bytecode(jsPath); + HILOG_INFO(HILOG_MODULE_AAFWK, "[BMS] delete byte code, result is %d", result); + AdapterFree(jsPath); + return; + } AdapterFree(jsPath); cJSON *resultObj = cJSON_CreateNumber(0); -- Gitee