diff --git a/.gitee/ISSUE_TEMPLATE.zh-CN.md b/.gitee/ISSUE_TEMPLATE.zh-CN.md new file mode 100644 index 0000000000000000000000000000000000000000..651e02cef6e623d3385eb4c83d633d73e141cd56 --- /dev/null +++ b/.gitee/ISSUE_TEMPLATE.zh-CN.md @@ -0,0 +1,11 @@ +### 该问题是怎么引起的? + + + +### 重现步骤 + + + +### 报错信息 + + diff --git a/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md b/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md new file mode 100644 index 0000000000000000000000000000000000000000..86dd358d3c204cd20eb207d5b1db7582f3632eea --- /dev/null +++ b/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md @@ -0,0 +1,12 @@ +### 相关的Issue + + +### 原因(目的、解决的问题等) + + +### 描述(做了什么,变更了什么) + + +### 测试用例(新增、改动、可能影响的功能) + + diff --git a/frameworks/bundle_lite/include/bundlems_slite_client.h b/frameworks/bundle_lite/include/bundlems_slite_client.h index 7c8ceb9c481ffff8409d50926250b101e419ea70..8e5d9ecf0bc8931cad6c93c661172b36737d58a3 100755 --- a/frameworks/bundle_lite/include/bundlems_slite_client.h +++ b/frameworks/bundle_lite/include/bundlems_slite_client.h @@ -47,6 +47,8 @@ public: bool GetInstallState(const char *bundleName, InstallState *installState, uint8_t *installProcess) const; + bool GetUninstallState(const char *bundleName, UninstallState *uninstallState) const; + private: BundleMsClient() = default; diff --git a/frameworks/bundle_lite/src/slite/bundle_manager_inner.cpp b/frameworks/bundle_lite/src/slite/bundle_manager_inner.cpp index cf3b4a5357ec5390e04b10943cff75e9e8881c01..853b04e503672acdb2eda87ef398e38682944d36 100755 --- a/frameworks/bundle_lite/src/slite/bundle_manager_inner.cpp +++ b/frameworks/bundle_lite/src/slite/bundle_manager_inner.cpp @@ -23,4 +23,9 @@ bool GetInstallState(const char *bundleName, InstallState *installState, uint8_t { return OHOS::BundleMsClient::GetInstance().GetInstallState(bundleName, installState, installProcess); } + +bool GetUninstallState(const char *bundleName, UninstallState *uninstallState) +{ + return OHOS::BundleMsClient::GetInstance().GetUninstallState(bundleName, uninstallState); +} } diff --git a/frameworks/bundle_lite/src/slite/bundlems_slite_client.cpp b/frameworks/bundle_lite/src/slite/bundlems_slite_client.cpp index 6b210ed5645d486933ecfc9183b40ebe0e35b25d..60a7185aa4458a8d773629cecb637dcee4393ea0 100755 --- a/frameworks/bundle_lite/src/slite/bundlems_slite_client.cpp +++ b/frameworks/bundle_lite/src/slite/bundlems_slite_client.cpp @@ -157,4 +157,12 @@ bool BundleMsClient::GetInstallState (const char *bundleName, InstallState *inst } return bmsProxy_->GetInstallState(bundleName, installState, installProcess); } + +bool BundleMsClient::GetUninstallState (const char *bundleName, UninstallState *uninstallState) const +{ + if (!Initialize()) { + return false; + } + return bmsProxy_->GetUninstallState(bundleName, uninstallState); +} } // namespace OHOS diff --git a/interfaces/innerkits/bundlemgr_lite/bundle_service_interface.h b/interfaces/innerkits/bundlemgr_lite/bundle_service_interface.h index 74f516f62f84dfea6cbac8570ff9402caba6231e..271375a9dfaa4c4fc7c7d997c98e0c9e2cae900e 100755 --- a/interfaces/innerkits/bundlemgr_lite/bundle_service_interface.h +++ b/interfaces/innerkits/bundlemgr_lite/bundle_service_interface.h @@ -50,6 +50,7 @@ struct BmsSliteInterface { uint8_t (*GetBundleInfo)(const char *bundleName, int32_t flags, BundleInfo *bundleInfo); uint8_t (*GetBundleInfos)(int32_t flags, BundleInfo **bundleInfos, int32_t *len); bool (*GetInstallState)(const char *bundleName, InstallState *installState, uint8_t *installProcess); + bool (*GetUninstallState)(const char *bundleName, UninstallState *uninstallState); }; #ifdef __cplusplus #if __cplusplus diff --git a/interfaces/innerkits/bundlemgr_lite/slite/bundle_install_msg.h b/interfaces/innerkits/bundlemgr_lite/slite/bundle_install_msg.h index 48dc2552afbffc10646564f67079dc4edd7e129c..552a04ad31e991a95f255a8b1ac2f0b6ffea4fcd 100644 --- a/interfaces/innerkits/bundlemgr_lite/slite/bundle_install_msg.h +++ b/interfaces/innerkits/bundlemgr_lite/slite/bundle_install_msg.h @@ -39,6 +39,12 @@ typedef struct { uint8_t installProcess; } BundleInstallMsg; +typedef enum { + BUNDLE_UNINSTALL_DOING = 0, + BUNDLE_UNINSTALL_OK = 1, + BUNDLE_UNINSTALL_FAIL = 2 +} UninstallState; + /** * @brief Get the install state and install process of the bundle. * @@ -52,6 +58,16 @@ typedef struct { */ bool GetInstallState(const char *bundleName, InstallState *installState, uint8_t *installProcess); +/** + * @brief Get the uninstall state and uninstall state of the bundle. + * + * @param bundleName Indicates the name of the bundle. + * @param uninstallState Obtains uninstall state. + * @return Returns success or not. + * + */ +bool GetUninstallState(const char *bundleName, UninstallState *uninstallState); + #ifdef __cplusplus #if __cplusplus } diff --git a/services/bundlemgr_lite/bundle_daemon/src/bundle_file_utils.cpp b/services/bundlemgr_lite/bundle_daemon/src/bundle_file_utils.cpp index 8c7d2d5d313182c8453236f4906315aa0541e6fe..6422d04001ff54118f3bd9e48ac1530a627a156a 100644 --- a/services/bundlemgr_lite/bundle_daemon/src/bundle_file_utils.cpp +++ b/services/bundlemgr_lite/bundle_daemon/src/bundle_file_utils.cpp @@ -142,6 +142,7 @@ bool BundleFileUtils::WriteFile(const char *file, const void *buffer, uint32_t s return false; } + fsync(fp); close(fp); return true; } diff --git a/services/bundlemgr_lite/include/bundle_mgr_slite_feature.h b/services/bundlemgr_lite/include/bundle_mgr_slite_feature.h index 0955f9e67aa942af111148e950f1b9327c7d3783..6bdfe1b81f88f060fa1bf4549d4fcf8c71af8b00 100755 --- a/services/bundlemgr_lite/include/bundle_mgr_slite_feature.h +++ b/services/bundlemgr_lite/include/bundle_mgr_slite_feature.h @@ -36,6 +36,7 @@ public: static uint8_t GetBundleInfo(const char *bundleName, int32_t flags, BundleInfo *bundleInfo); static uint8_t GetBundleInfos(int32_t flags, BundleInfo **bundleInfos, int32_t *len); static bool GetInstallState(const char *bundleName, InstallState *installState, uint8_t *installProcess); + static bool GetUninstallState(const char *bundleName, UninstallState *uninstallState); static BundleMgrSliteFeature *GetInstance() { diff --git a/services/bundlemgr_lite/include/gt_bundle_installer.h b/services/bundlemgr_lite/include/gt_bundle_installer.h index 5d2a7e701fc9e78397a470f91197fa7bddf79581..ed558e541c792c9ae8ebaf0372c50a78b7fb5ff5 100755 --- a/services/bundlemgr_lite/include/gt_bundle_installer.h +++ b/services/bundlemgr_lite/include/gt_bundle_installer.h @@ -16,11 +16,10 @@ #ifndef OHOS_GT_BUNDLE_INSTALLER_H #define OHOS_GT_BUNDLE_INSTALLER_H -#include "generate-bytecode.h" - #ifdef __cplusplus extern "C" { #endif +#include "generate-bytecode.h" #ifdef __cplusplus } #endif diff --git a/services/bundlemgr_lite/include/gt_bundle_manager_service.h b/services/bundlemgr_lite/include/gt_bundle_manager_service.h index 321c080babe74dd48fae8941073c9f94ade7280b..ff09786db6f466993a95e5c38c7c6f2ee2c76172 100755 --- a/services/bundlemgr_lite/include/gt_bundle_manager_service.h +++ b/services/bundlemgr_lite/include/gt_bundle_manager_service.h @@ -49,6 +49,11 @@ typedef enum { BUNDLE_UPDATE, } BundleState; +typedef struct { + char *bundleName; + UninstallState uninstallState; +} BundleUninstallMsg; + class GtManagerService { public: static GtManagerService &GetInstance() @@ -75,7 +80,10 @@ public: void ReduceNumOfThirdBundles(); int32_t ReportInstallCallback(uint8_t errCode, uint8_t installState, uint8_t process, InstallerCallback installerCallback); + int32_t ReportUninstallCallback(uint8_t errCode, char *bundleName, + uint8_t process, InstallerCallback installerCallback); bool GetInstallState(const char *bundleName, InstallState *installState, uint8_t *installProcess); + bool GetUninstallState(const char *bundleName, UninstallState *uninstallState); private: GtManagerService(); @@ -105,6 +113,7 @@ private: BundleMap *bundleMap_; List *bundleResList_; BundleInstallMsg *bundleInstallMsg_; + BundleUninstallMsg *bundleUninstallMsg_; char *jsEngineVer_; uint32_t installedThirdBundleNum_; }; diff --git a/services/bundlemgr_lite/src/bundle_mgr_slite_feature.cpp b/services/bundlemgr_lite/src/bundle_mgr_slite_feature.cpp index 0734c40e8a2aa3fef155dc14f21c57c72204fd26..4a019ee71175d7a389605cbe9775e720b649b7fe 100755 --- a/services/bundlemgr_lite/src/bundle_mgr_slite_feature.cpp +++ b/services/bundlemgr_lite/src/bundle_mgr_slite_feature.cpp @@ -33,6 +33,7 @@ BundleMgrSliteFeatureImpl g_bmsSliteImpl = { .GetBundleInfo = BundleMgrSliteFeature::GetBundleInfo, .GetBundleInfos = BundleMgrSliteFeature::GetBundleInfos, .GetInstallState = BundleMgrSliteFeature::GetInstallState, + .GetUninstallState = BundleMgrSliteFeature::GetUninstallState, DEFAULT_IUNKNOWN_ENTRY_END }; @@ -126,4 +127,9 @@ bool BundleMgrSliteFeature::GetInstallState(const char *bundleName, InstallState { return OHOS::GtManagerService::GetInstance().GetInstallState(bundleName, installState, installProcess); } + +bool BundleMgrSliteFeature::GetUninstallState(const char *bundleName, UninstallState *uninstallState) +{ + return OHOS::GtManagerService::GetInstance().GetUninstallState(bundleName, uninstallState); +} } // namespace OHOS diff --git a/services/bundlemgr_lite/src/extractor_util.cpp b/services/bundlemgr_lite/src/extractor_util.cpp index 4ac98cb00856bd9584f5c833197d02999eea4995..935f9a6f846375b3a2954a7dcc0a40e5d5baf19d 100755 --- a/services/bundlemgr_lite/src/extractor_util.cpp +++ b/services/bundlemgr_lite/src/extractor_util.cpp @@ -15,7 +15,11 @@ #include "extractor_util.h" +#include +#include #include +#include +#include #include "log.h" @@ -62,6 +66,10 @@ bool ExtractorUtil::ExtractFileToPath(const std::string &filePath, const std::st } fileStream.clear(); fileStream.close(); + + int fd = open(filePath.c_str(), O_RDWR, S_IRUSR | S_IWUSR); + fsync(fd); + close(fd); return true; } diff --git a/services/bundlemgr_lite/src/gt_bundle_installer.cpp b/services/bundlemgr_lite/src/gt_bundle_installer.cpp index 1295121d88561e49da81d758d7a6a91ab6f9e9cf..69eeefcd9b7d94ebcd3e7dbe29b2ff93c20b3a2d 100755 --- a/services/bundlemgr_lite/src/gt_bundle_installer.cpp +++ b/services/bundlemgr_lite/src/gt_bundle_installer.cpp @@ -234,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; @@ -470,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 3948e9af11c5d8d112bbb301951d9e8f560da909..6c655cadb17a53956e90f9a5d03b0d50988c0b55 100755 --- a/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp +++ b/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp @@ -25,10 +25,10 @@ #include "cmsis_os2.h" #include "dirent.h" #include "fcntl.h" -#include "generate-bytecode.h" #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" @@ -50,6 +50,7 @@ GtManagerService::GtManagerService() bundleResList_ = new List(); bundleMap_ = BundleMap::GetInstance(); bundleInstallMsg_ = nullptr; + bundleUninstallMsg_ = nullptr; jsEngineVer_ = nullptr; installedThirdBundleNum_ = 0; } @@ -111,9 +112,9 @@ bool GtManagerService::Install(const char *hapPath, const InstallParam *installP uint8_t ret = installer_->Install(path, installerCallback); EnableServiceWdg(); if (ret == 0) { - (void) ReportInstallCallback(ret, 1, BMS_INSTALLATION_COMPLETED, installerCallback); + (void) ReportInstallCallback(ret, BUNDLE_INSTALL_OK, BMS_INSTALLATION_COMPLETED, installerCallback); } else { - (void) ReportInstallCallback(ret, 2, BMS_INSTALLATION_COMPLETED, installerCallback); + (void) ReportInstallCallback(ret, BUNDLE_INSTALL_FAIL, BMS_INSTALLATION_COMPLETED, installerCallback); } (void) BundleUtil::RemoveDir(TMP_RESOURCE_DIR); SetCurrentBundle(nullptr); @@ -144,21 +145,31 @@ bool GtManagerService::Uninstall(const char *bundleName, const InstallParam *ins return false; } SetCurrentBundle(innerBundleName); - bundleInstallMsg_ = reinterpret_cast(AdapterMalloc(sizeof(BundleInstallMsg))); - if (bundleInstallMsg_ == nullptr) { + + bundleUninstallMsg_ = reinterpret_cast(AdapterMalloc(sizeof(BundleUninstallMsg))); + if (bundleUninstallMsg_ == nullptr) { return false; } - if (memset_s(bundleInstallMsg_, sizeof(BundleInstallMsg), 0, sizeof(BundleInstallMsg)) != EOK) { - AdapterFree(bundleInstallMsg_); + if (memset_s(bundleUninstallMsg_, sizeof(BundleUninstallMsg), 0, sizeof(BundleUninstallMsg)) != EOK) { + AdapterFree(bundleUninstallMsg_); return false; } - bundleInstallMsg_->bundleName = Utils::Strdup(innerBundleName); - (void) ReportInstallCallback(OPERATION_DOING, 0, BMS_UNINSTALLATION_START, installerCallback); + bundleUninstallMsg_->bundleName = innerBundleName; + bundleUninstallMsg_->uninstallState = BUNDLE_UNINSTALL_DOING; + + (void) ReportUninstallCallback(OPERATION_DOING, innerBundleName, BMS_UNINSTALLATION_START, installerCallback); uint8_t ret = installer_->Uninstall(innerBundleName); - (void) ReportInstallCallback(ret, 0, BMS_INSTALLATION_COMPLETED, installerCallback); - ClearSystemBundleInstallMsg(); + if (ret == 0) { + bundleUninstallMsg_->uninstallState = BUNDLE_UNINSTALL_OK; + } else { + bundleUninstallMsg_->uninstallState = BUNDLE_UNINSTALL_FAIL; + } + (void) ReportUninstallCallback(ret, innerBundleName, BMS_INSTALLATION_COMPLETED, installerCallback); + SetCurrentBundle(nullptr); AdapterFree(innerBundleName); + AdapterFree(bundleUninstallMsg_); + bundleUninstallMsg_ = nullptr; return true; } @@ -170,7 +181,7 @@ bool GtManagerService::GetInstallState(const char *bundleName, InstallState *ins *installProcess = BMS_INSTALLATION_COMPLETED; return true; } - if (bundleName == bundleInstallMsg_->bundleName) { + if (strcmp(bundleName, bundleInstallMsg_->bundleName) == 0) { *installState = bundleInstallMsg_->installState; *installProcess = bundleInstallMsg_->installProcess; return true; @@ -180,6 +191,21 @@ bool GtManagerService::GetInstallState(const char *bundleName, InstallState *ins return true; } +bool GtManagerService::GetUninstallState(const char *bundleName, UninstallState *uninstallState) +{ + BundleInfo *uninstalledInfo = bundleMap_->Get(bundleName); + if (uninstalledInfo == nullptr) { + *uninstallState = BUNDLE_UNINSTALL_OK; + return true; + } + if (strcmp(bundleName, bundleUninstallMsg_->bundleName) == 0) { + *uninstallState = bundleUninstallMsg_->uninstallState; + return true; + } + *uninstallState = BUNDLE_UNINSTALL_DOING; + return true; +} + uint8_t GtManagerService::QueryAbilityInfo(const Want *want, AbilityInfo *abilityInfo) { if (want->element == nullptr) { @@ -310,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(); @@ -717,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); @@ -847,11 +887,26 @@ int32_t GtManagerService::ReportInstallCallback(uint8_t errCode, uint8_t install bundleInstallMsg->bundleName = bundleInstallMsg_->bundleName; bundleInstallMsg->smallIconPath = bundleInstallMsg_->smallIconPath; bundleInstallMsg->bigIconPath = bundleInstallMsg_->bigIconPath; - (*installerCallback)(errCode, bundleInstallMsg); return 0; } +int32_t GtManagerService::ReportUninstallCallback(uint8_t errCode, char *bundleName, + uint8_t process, InstallerCallback installerCallback) +{ + if (installerCallback == nullptr) { + return -1; + } + BundleInstallMsg *bundleUninstallMsg = reinterpret_cast(AdapterMalloc(sizeof(BundleInstallMsg))); + if (bundleUninstallMsg == nullptr) { + return -1; + } + bundleUninstallMsg->bundleName = bundleName; + bundleUninstallMsg->installProcess = process; + (*installerCallback)(errCode, bundleUninstallMsg); + return 0; +} + AppInfoList *GtManagerService::APP_InitAllAppInfo() { AppInfoList *list = (AppInfoList *)AdapterMalloc(sizeof(AppInfoList));