From 9a137db939c68edc6f81fdbdaa30bb7447bbbcb8 Mon Sep 17 00:00:00 2001 From: shilei Date: Mon, 21 Nov 2022 16:58:47 +0800 Subject: [PATCH] add Signed-off-by: shilei --- frameworks/bundle_lite/BUILD.gn | 1 - services/bundlemgr_lite/BUILD.gn | 8 +++++++- .../bundlemgr_lite/src/gt_bundle_extractor.cpp | 6 +++--- .../bundlemgr_lite/src/gt_bundle_installer.cpp | 17 +++++++++++------ .../src/gt_bundle_manager_service.cpp | 18 ++++++++++++------ .../bundlemgr_lite/src/gt_extractor_util.cpp | 2 +- 6 files changed, 34 insertions(+), 18 deletions(-) diff --git a/frameworks/bundle_lite/BUILD.gn b/frameworks/bundle_lite/BUILD.gn index 5b18e9d..6d11471 100644 --- a/frameworks/bundle_lite/BUILD.gn +++ b/frameworks/bundle_lite/BUILD.gn @@ -61,7 +61,6 @@ lite_library("bundle") { "${aafwk_lite_path}/interfaces/kits/want_lite", "${aafwk_lite_path}/interfaces/kits/ability_lite/slite", "${aafwk_lite_path}/interfaces/inner_api/abilitymgr_lite", - "//foundation/communication/ipc/interfaces/innerkits/c/ipc/include", "//foundation/systemabilitymgr/samgr_lite/interfaces/kits/samgr", "//foundation/systemabilitymgr/samgr_lite/interfaces/kits/registry", "//third_party/bounds_checking_function/include", diff --git a/services/bundlemgr_lite/BUILD.gn b/services/bundlemgr_lite/BUILD.gn index ae3080a..6f27ac0 100644 --- a/services/bundlemgr_lite/BUILD.gn +++ b/services/bundlemgr_lite/BUILD.gn @@ -17,6 +17,10 @@ config("bundle_config") { cflags_cc = [ "-std=c++14" ] } +declare_args() { + enable_ohos_bundle_manager_service = false +} + if (ohos_kernel_type == "liteos_m") { static_library("bundlems") { sources = [ @@ -32,6 +36,9 @@ if (ohos_kernel_type == "liteos_m") { ] defines = ["JERRY_FOR_IAR_CONFIG"] + if (enable_ohos_bundle_manager_service == true) { + defines += [ "_MINI_BMS_" ] + } deps = [ "${appexecfwk_lite_path}/frameworks/bundle_lite:bundle", @@ -61,7 +68,6 @@ if (ohos_kernel_type == "liteos_m") { "//base/global/resource_management_lite/interfaces/inner_api/include", "//foundation/systemabilitymgr/samgr_lite/interfaces/kits/registry", "//foundation/systemabilitymgr/samgr_lite/interfaces/kits/samgr", - "//foundation/communication/ipc/interfaces/innerkits/c/ipc/include", "//third_party/jerryscript/jerry-core", "//third_party/jerryscript/jerry-core/api", "//third_party/jerryscript/jerry-core/ecma/base", diff --git a/services/bundlemgr_lite/src/gt_bundle_extractor.cpp b/services/bundlemgr_lite/src/gt_bundle_extractor.cpp index 9c9e675..32de443 100644 --- a/services/bundlemgr_lite/src/gt_bundle_extractor.cpp +++ b/services/bundlemgr_lite/src/gt_bundle_extractor.cpp @@ -186,14 +186,14 @@ uint8_t GtBundleExtractor::ExtractInstallMsg(const char *path, char **bundleName if (!BundleUtil::CheckRealPath(path)) { return ERR_APPEXECFWK_INSTALL_FAILED_PARAM_ERROR; } -#ifdef __LITEOS_M__ - int32_t totalFileSize = BundleUtil::GetFileSize(path); -#else +#ifdef _MINI_BMS_ int32_t totalFileSize = APPVERI_GetUnsignedFileLength(path); if (totalFileSize == V_ERR) { HILOG_ERROR(HILOG_MODULE_AAFWK, "[BMS] get unsigned file length failed!"); return ERR_APPEXECFWK_INSTALL_FAILED_INTERNAL_ERROR; } +#else + int32_t totalFileSize = BundleUtil::GetFileSize(path); #endif char *emptyJsPathComp[] = {const_cast(TMP_RESOURCE_DIR), const_cast(ASSET_JS_PATH)}; char *emptyJsPath = BundleUtil::Strscat(emptyJsPathComp, sizeof(emptyJsPathComp) / sizeof(char *)); diff --git a/services/bundlemgr_lite/src/gt_bundle_installer.cpp b/services/bundlemgr_lite/src/gt_bundle_installer.cpp index 6ffb76e..058cd02 100644 --- a/services/bundlemgr_lite/src/gt_bundle_installer.cpp +++ b/services/bundlemgr_lite/src/gt_bundle_installer.cpp @@ -107,7 +107,7 @@ uint8_t GtBundleInstaller::PreCheckBundle(const char *path, int32_t &fp, Signatu uint8_t GtBundleInstaller::VerifySignature(const char *path, SignatureInfo &signatureInfo, uint32_t &fileSize, uint8_t bundleStyle) { -#ifndef __LITEOS_M__ +#ifdef _MINI_BMS_ VerifyResult verifyResult; // verify signature (void) APPVERI_SetDebugMode(true); @@ -252,16 +252,21 @@ uint8_t GtBundleInstaller::ProcessBundleInstall(const char *path, const char *ra uint32_t iconId = (bundleRes.abilityRes != nullptr) ? bundleRes.abilityRes->iconId : 0; AdapterFree(bundleRes.abilityRes); // check signatureInfo -#ifndef __LITEOS_M__ +#ifdef _MINI_BMS_ errorCode = CheckProvisionInfoIsValid(signatureInfo, permissions, bundleInfo->bundleName); CHECK_PRO_RESULT(errorCode, fp, permissions, bundleInfo, signatureInfo); #endif installRecord.codePath = bundleInfo->codePath; installRecord.bundleName = bundleInfo->bundleName; +#ifdef _MINI_BMS_ + installRecord.appId = signatureInfo.appId; + bundleInfo->appId = Utils::Strdup(signatureInfo.appId); +#else char innerAppId[] = "appId"; installRecord.appId = innerAppId; - installRecord.versionCode = bundleInfo->versionCode; bundleInfo->appId = Utils::Strdup(innerAppId); +#endif + installRecord.versionCode = bundleInfo->versionCode; // check version when in update status errorCode = CheckVersionAndSignature(installRecord.bundleName, installRecord.appId, bundleInfo); CHECK_PRO_RESULT(errorCode, fp, permissions, bundleInfo, signatureInfo); @@ -586,7 +591,7 @@ uint8_t GtBundleInstaller::Uninstall(const char *bundleName) if (sprintf_s(bundleJsonPath, PATH_LENGTH, "%s%s%s", JSON_PATH, bundleName, JSON_SUFFIX) < 0) { return ERR_APPEXECFWK_UNINSTALL_FAILED_INTERNAL_ERROR; } -#ifndef __LITEOS_M__ +#ifdef _MINI_BMS_ if (DeletePermissions(const_cast(bundleName)) < 0) { return ERR_APPEXECFWK_UNINSTALL_FAILED_DELETE_PERMISSIONS_ERROR; } @@ -743,7 +748,7 @@ uint8_t GtBundleInstaller::StorePermissions(const char *bundleName, PermissionTr bool isUpdate) { if (permNum == 0) { -#ifndef __LITEOS_M__ +#ifdef _MINI_BMS_ if (isUpdate) { int32_t ret = DeletePermissions(bundleName); HILOG_INFO(HILOG_MODULE_AAFWK, "[BMS] delete permissions, result is %d", ret); @@ -759,7 +764,7 @@ uint8_t GtBundleInstaller::StorePermissions(const char *bundleName, PermissionTr if (!BundleUtil::IsDir(PERMISSIONS_PATH)) { BundleUtil::MkDirs(PERMISSIONS_PATH); } -#ifndef __LITEOS_M__ +#ifdef _MINI_BMS_ if (SaveOrUpdatePermissions(const_cast(bundleName), permissions, permNum, static_cast(isUpdate)) != 0) { return ERR_APPEXECFWK_INSTALL_FAILED_STORE_PERMISSIONS_ERROR; diff --git a/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp b/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp index 61f763f..adcb1f5 100644 --- a/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp +++ b/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp @@ -126,11 +126,11 @@ bool GtManagerService::Install(const char *hapPath, const InstallParam *installP SetCurrentBundle(bundleInstallMsg_->bundleName); (void) ReportInstallCallback(OPERATION_DOING, 0, BMS_INSTALLATION_START, installerCallback); -#ifdef BC_TRANS_ENABLE +#ifdef _MINI_BMS_ DisableServiceWdg(); #endif ret = installer_->Install(path, installerCallback); -#ifdef BC_TRANS_ENABLE +#ifdef _MINI_BMS_ EnableServiceWdg(); #endif HILOG_INFO(HILOG_MODULE_AAFWK, "[BMS] Install ret is %d", ret); @@ -171,11 +171,11 @@ bool GtManagerService::Uninstall(const char *bundleName, const InstallParam *ins (void) ReportUninstallCallback(OPERATION_DOING, BUNDLE_UNINSTALL_DOING, innerBundleName, BMS_UNINSTALLATION_START, installerCallback); -#ifdef BC_TRANS_ENABLE +#ifdef _MINI_BMS_ DisableServiceWdg(); #endif uint8_t ret = installer_->Uninstall(innerBundleName); -#ifdef BC_TRANS_ENABLE +#ifdef _MINI_BMS_ EnableServiceWdg(); #endif HILOG_INFO(HILOG_MODULE_AAFWK, "[BMS] Uninstall ret is %d", ret); @@ -310,7 +310,7 @@ void GtManagerService::InstallPreBundle(List systemPathList, } // scan system apps and third system apps -#ifdef BC_TRANS_ENABLE +#ifdef _MINI_BMS_ DisableServiceWdg(); #endif ScanSystemApp(uninstallRecord, &systemPathList_); @@ -320,7 +320,7 @@ void GtManagerService::InstallPreBundle(List systemPathList, // scan third apps ScanThirdApp(INSTALL_PATH, &systemPathList_); -#ifdef BC_TRANS_ENABLE +#ifdef _MINI_BMS_ EnableServiceWdg(); #endif for (auto node = systemPathList.Begin(); node != systemPathList.End(); node = node->next_) { @@ -350,6 +350,9 @@ void GtManagerService::InstallAllSystemBundle(InstallerCallback installerCallbac PreAppList *currentNode = nullptr; PreAppList *nextNode = nullptr; LOS_DL_LIST_FOR_EACH_ENTRY_SAFE(currentNode, nextNode, &list->appDoubleList, PreAppList, appDoubleList) { + if (currentNode == nullptr) { + return; + } if ((strcmp(((PreAppList *)currentNode)->filePath, ".") == 0) || (strcmp(((PreAppList *)currentNode)->filePath, "..") == 0)) { continue; @@ -492,6 +495,9 @@ void GtManagerService::ScanThirdApp(const char *appDir, const List(AdapterMalloc(MAX_BUNDLE_NAME_LEN + 1)); + if (bundleName == nullptr) { + return; + } int32_t entLen = 0; while ((ent = readdir(dir)) != nullptr) { ++entLen; diff --git a/services/bundlemgr_lite/src/gt_extractor_util.cpp b/services/bundlemgr_lite/src/gt_extractor_util.cpp index 0485c06..cdfff6d 100644 --- a/services/bundlemgr_lite/src/gt_extractor_util.cpp +++ b/services/bundlemgr_lite/src/gt_extractor_util.cpp @@ -34,7 +34,7 @@ const uint8_t SHIFT_NUM = 8; uint32_t GtExtractorUtil::ReadInt(int32_t fp) { unsigned char buf[INT_LENGTH] = {0}; - if (read(fp, buf, INT_LENGTH) != INT_LENGTH) { + if (read(fp, buf, INT_LENGTH) != INT_LENGTH) { return UINT_MAX; } -- Gitee