diff --git a/frameworks/bundle_lite/BUILD.gn b/frameworks/bundle_lite/BUILD.gn index 5b18e9d114406d56a19a6e3403b67ca26700cce8..6d11471e8b5df1a83309e8248b9877893fbb35ff 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 5a8280e46260e16fedde96bf36fd35566411e1bd..39cd1fc624c17c9e8e3b55914e7fdde2847b6600 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 9c9e675b7e9f4aa5909c5475bb7df6f3662c2293..32de443a60d93e28d4c1a9f2044cfed06ddaeb33 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 6ffb76ee4a87d2d92dda4f734bd4bfee97f96bb1..1361b6309107a394de976f95f47ff70fa6cf8a9c 100644 --- a/services/bundlemgr_lite/src/gt_bundle_installer.cpp +++ b/services/bundlemgr_lite/src/gt_bundle_installer.cpp @@ -46,7 +46,6 @@ const uint8_t BMS_FOURTH_FINISHED_PROCESS = 70; const uint8_t BMS_FIFTH_FINISHED_PROCESS = 80; const uint8_t BMS_SIXTH_FINISHED_PROCESS = 90; const uint8_t RADN_NUM = 16; - uint8_t GtBundleInstaller::PreCheckBundle(const char *path, int32_t &fp, SignatureInfo &signatureInfo, uint32_t &fileSize, uint8_t bundleStyle) { @@ -107,7 +106,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 +251,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 +590,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 +747,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 +763,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 61f763f325763435d98cfb12fad98824f188d4d1..adcb1f5e57a9a5855c9b260096145e45cc2327ee 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 0485c06aca5e699aff016e51274192cfbd5affd2..cdfff6de129fa7549503da42a6156e8110c606de 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; }