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 ae3080ac9ccc5e240b8b003218d256c780705a38..6f27ac0f5b581fe084468fb09c3c5f3cfc9895f4 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 7bf71ee3ef924c58b7cd72e90e68cf06ac065aab..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,11 +590,11 @@ 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; } - +#ifdef _MINI_BMS_ if (DeletePermissions(const_cast(bundleName)) < 0) { return ERR_APPEXECFWK_UNINSTALL_FAILED_DELETE_PERMISSIONS_ERROR; } - +#endif bool res = CheckIsThirdSystemBundle(bundleName); if (!(BundleUtil::RemoveDir(bundleInfo->codePath) && BundleUtil::RemoveDir(bundleInfo->dataPath))) { GtManagerService::GetInstance().RemoveBundleInfo(bundleName); @@ -743,10 +747,12 @@ uint8_t GtBundleInstaller::StorePermissions(const char *bundleName, PermissionTr bool isUpdate) { if (permNum == 0) { +#ifdef _MINI_BMS_ if (isUpdate) { int32_t ret = DeletePermissions(bundleName); HILOG_INFO(HILOG_MODULE_AAFWK, "[BMS] delete permissions, result is %d", ret); } +#endif return ERR_OK; } @@ -757,11 +763,12 @@ uint8_t GtBundleInstaller::StorePermissions(const char *bundleName, PermissionTr if (!BundleUtil::IsDir(PERMISSIONS_PATH)) { BundleUtil::MkDirs(PERMISSIONS_PATH); } - +#ifdef _MINI_BMS_ if (SaveOrUpdatePermissions(const_cast(bundleName), permissions, permNum, static_cast(isUpdate)) != 0) { return ERR_APPEXECFWK_INSTALL_FAILED_STORE_PERMISSIONS_ERROR; } +#endif return ERR_OK; } diff --git a/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp b/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp index 2001898f08f326e2209eed47748a2cba1ba9dc16..adcb1f5e57a9a5855c9b260096145e45cc2327ee 100644 --- a/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp +++ b/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp @@ -126,9 +126,13 @@ bool GtManagerService::Install(const char *hapPath, const InstallParam *installP SetCurrentBundle(bundleInstallMsg_->bundleName); (void) ReportInstallCallback(OPERATION_DOING, 0, BMS_INSTALLATION_START, installerCallback); +#ifdef _MINI_BMS_ DisableServiceWdg(); +#endif ret = installer_->Install(path, installerCallback); +#ifdef _MINI_BMS_ EnableServiceWdg(); +#endif HILOG_INFO(HILOG_MODULE_AAFWK, "[BMS] Install ret is %d", ret); if (ret == 0) { (void) ReportInstallCallback(ret, BUNDLE_INSTALL_OK, BMS_INSTALLATION_COMPLETED, installerCallback); @@ -167,9 +171,13 @@ bool GtManagerService::Uninstall(const char *bundleName, const InstallParam *ins (void) ReportUninstallCallback(OPERATION_DOING, BUNDLE_UNINSTALL_DOING, innerBundleName, BMS_UNINSTALLATION_START, installerCallback); +#ifdef _MINI_BMS_ DisableServiceWdg(); +#endif uint8_t ret = installer_->Uninstall(innerBundleName); +#ifdef _MINI_BMS_ EnableServiceWdg(); +#endif HILOG_INFO(HILOG_MODULE_AAFWK, "[BMS] Uninstall ret is %d", ret); if (ret == 0) { (void) ReportUninstallCallback(ret, BUNDLE_UNINSTALL_OK, innerBundleName, @@ -302,7 +310,9 @@ void GtManagerService::InstallPreBundle(List systemPathList, } // scan system apps and third system apps +#ifdef _MINI_BMS_ DisableServiceWdg(); +#endif ScanSystemApp(uninstallRecord, &systemPathList_); if (uninstallRecord != nullptr) { cJSON_Delete(uninstallRecord); @@ -310,7 +320,9 @@ void GtManagerService::InstallPreBundle(List systemPathList, // scan third apps ScanThirdApp(INSTALL_PATH, &systemPathList_); +#ifdef _MINI_BMS_ EnableServiceWdg(); +#endif for (auto node = systemPathList.Begin(); node != systemPathList.End(); node = node->next_) { ToBeInstalledApp *toBeInstalledApp = node->value_; if (!BundleUtil::IsFile(toBeInstalledApp->path) || @@ -338,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; @@ -480,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; @@ -766,6 +784,7 @@ void GtManagerService::UpdateBundleInfoList() } } +#ifdef BC_TRANS_ENABLE void GtManagerService::TransformJsToBcWhenRestart(const char *codePath, const char *bundleName) { if (codePath == nullptr) { @@ -876,6 +895,7 @@ void GtManagerService::TransformJsToBc(const char *codePath, const char *bundleJ } (void)BundleUtil::StoreJsonContentToFile(bundleJsonPath, installRecordObj); } +#endif bool GtManagerService::CheckThirdSystemBundleHasUninstalled(const char *bundleName, const cJSON *object) { 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; }