From 34a700a1662c7bd0f2017f3f0183aa47d1477f08 Mon Sep 17 00:00:00 2001 From: shilei Date: Wed, 9 Nov 2022 14:38:10 +0800 Subject: [PATCH 1/8] fixed 3340c13 from https://gitee.com/shilei91/bundlemanager_bundle_framework_lite/pulls/226 add Signed-off-by: shilei Change-Id: I7e95213f27e39e45021e09e36b0162c5caf542c5 --- .../bundlemgr_lite/src/gt_bundle_installer.cpp | 9 ++++++--- .../src/gt_bundle_manager_service.cpp | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/services/bundlemgr_lite/src/gt_bundle_installer.cpp b/services/bundlemgr_lite/src/gt_bundle_installer.cpp index 7bf71ee..6ffb76e 100644 --- a/services/bundlemgr_lite/src/gt_bundle_installer.cpp +++ b/services/bundlemgr_lite/src/gt_bundle_installer.cpp @@ -586,11 +586,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; } - +#ifndef __LITEOS_M__ 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 +743,12 @@ uint8_t GtBundleInstaller::StorePermissions(const char *bundleName, PermissionTr bool isUpdate) { if (permNum == 0) { +#ifndef __LITEOS_M__ 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 +759,12 @@ uint8_t GtBundleInstaller::StorePermissions(const char *bundleName, PermissionTr if (!BundleUtil::IsDir(PERMISSIONS_PATH)) { BundleUtil::MkDirs(PERMISSIONS_PATH); } - +#ifndef __LITEOS_M__ 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 2001898..61f763f 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 BC_TRANS_ENABLE DisableServiceWdg(); +#endif ret = installer_->Install(path, installerCallback); +#ifdef BC_TRANS_ENABLE 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 BC_TRANS_ENABLE DisableServiceWdg(); +#endif uint8_t ret = installer_->Uninstall(innerBundleName); +#ifdef BC_TRANS_ENABLE 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 BC_TRANS_ENABLE 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 BC_TRANS_ENABLE EnableServiceWdg(); +#endif for (auto node = systemPathList.Begin(); node != systemPathList.End(); node = node->next_) { ToBeInstalledApp *toBeInstalledApp = node->value_; if (!BundleUtil::IsFile(toBeInstalledApp->path) || @@ -766,6 +778,7 @@ void GtManagerService::UpdateBundleInfoList() } } +#ifdef BC_TRANS_ENABLE void GtManagerService::TransformJsToBcWhenRestart(const char *codePath, const char *bundleName) { if (codePath == nullptr) { @@ -876,6 +889,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) { -- Gitee From 528268597ae8fb9a211fbb0769f8cb937e0500f6 Mon Sep 17 00:00:00 2001 From: shilei Date: Mon, 14 Nov 2022 17:42:31 +0800 Subject: [PATCH 2/8] add Signed-off-by: shilei --- .../bundlemgr_lite/src/gt_bundle_extractor.cpp | 6 +++--- .../bundlemgr_lite/src/gt_bundle_installer.cpp | 18 +++++++++++------- .../src/gt_bundle_manager_service.cpp | 12 ++++++------ 3 files changed, 20 insertions(+), 16 deletions(-) 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..1361b63 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 61f763f..af652b4 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_) { -- Gitee From 4ba15057ffcdafa70c2b2c7c678f4652a8f35766 Mon Sep 17 00:00:00 2001 From: shilei91 Date: Fri, 18 Nov 2022 08:51:22 +0000 Subject: [PATCH 3/8] update frameworks/bundle_lite/BUILD.gn. Signed-off-by: shilei91 --- frameworks/bundle_lite/BUILD.gn | 1 - 1 file changed, 1 deletion(-) 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", -- Gitee From ffebc74f7b8c69463f94dc640d13c59e0416596f Mon Sep 17 00:00:00 2001 From: shilei91 Date: Fri, 18 Nov 2022 08:52:00 +0000 Subject: [PATCH 4/8] update services/bundlemgr_lite/BUILD.gn. Signed-off-by: shilei91 --- services/bundlemgr_lite/BUILD.gn | 1 - 1 file changed, 1 deletion(-) diff --git a/services/bundlemgr_lite/BUILD.gn b/services/bundlemgr_lite/BUILD.gn index ae3080a..dd34de7 100644 --- a/services/bundlemgr_lite/BUILD.gn +++ b/services/bundlemgr_lite/BUILD.gn @@ -61,7 +61,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", -- Gitee From d52be92497e3083841999e1efc324a949099e663 Mon Sep 17 00:00:00 2001 From: shilei91 Date: Fri, 18 Nov 2022 08:52:56 +0000 Subject: [PATCH 5/8] update services/bundlemgr_lite/src/gt_extractor_util.cpp. Signed-off-by: shilei91 --- services/bundlemgr_lite/src/gt_extractor_util.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 57b4872010736771377b4f8d9fe19714898b9eee Mon Sep 17 00:00:00 2001 From: shilei91 Date: Fri, 18 Nov 2022 09:01:57 +0000 Subject: [PATCH 6/8] update services/bundlemgr_lite/src/gt_bundle_manager_service.cpp. Signed-off-by: shilei91 --- services/bundlemgr_lite/src/gt_bundle_manager_service.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp b/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp index af652b4..c236d87 100644 --- a/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp +++ b/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp @@ -492,6 +492,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; -- Gitee From 1502a059883c6eac72e087e1a2fe39684362b851 Mon Sep 17 00:00:00 2001 From: shilei91 Date: Fri, 18 Nov 2022 09:04:55 +0000 Subject: [PATCH 7/8] update services/bundlemgr_lite/src/gt_bundle_manager_service.cpp. Signed-off-by: shilei91 --- services/bundlemgr_lite/src/gt_bundle_manager_service.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp b/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp index c236d87..adcb1f5 100644 --- a/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp +++ b/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp @@ -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; -- Gitee From f32a486d5b185f3981d54a8af7e2c49a4da7eb70 Mon Sep 17 00:00:00 2001 From: shilei91 Date: Mon, 21 Nov 2022 14:07:44 +0000 Subject: [PATCH 8/8] update services/bundlemgr_lite/BUILD.gn. Signed-off-by: shilei91 --- services/bundlemgr_lite/BUILD.gn | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/services/bundlemgr_lite/BUILD.gn b/services/bundlemgr_lite/BUILD.gn index dd34de7..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", -- Gitee