From f3409228fb7c76515f306a9a1956078776a9c185 Mon Sep 17 00:00:00 2001 From: shilei Date: Fri, 17 Mar 2023 09:31:31 +0000 Subject: [PATCH] fixed 8bb8ad4 from https://gitee.com/shilei91/bundlemanager_bundle_framework_lite/pulls/246 fix problem Signed-off-by: shilei Change-Id: Ie8187f2078ac49bdc4b13c80469637232112721a --- services/bundlemgr_lite/include/bundle_util.h | 4 ++++ .../bundlemgr_lite/include/gt_bundle_manager_service.h | 1 + services/bundlemgr_lite/include/gt_extractor_util.h | 4 ++++ services/bundlemgr_lite/src/bundle_util.cpp | 3 +++ services/bundlemgr_lite/src/gt_bundle_installer.cpp | 6 +++++- services/bundlemgr_lite/src/gt_bundle_manager_service.cpp | 8 ++++++++ services/bundlemgr_lite/src/gt_extractor_util.cpp | 1 + 7 files changed, 26 insertions(+), 1 deletion(-) diff --git a/services/bundlemgr_lite/include/bundle_util.h b/services/bundlemgr_lite/include/bundle_util.h index 76c45fc..1b316f8 100755 --- a/services/bundlemgr_lite/include/bundle_util.h +++ b/services/bundlemgr_lite/include/bundle_util.h @@ -78,4 +78,8 @@ private: #endif }; // namespace OHOS } + +extern "C" { +void RefreshAllServiceTimeStamp(void); +} #endif // OHOS_BUNDLE_UTIL_H diff --git a/services/bundlemgr_lite/include/gt_bundle_manager_service.h b/services/bundlemgr_lite/include/gt_bundle_manager_service.h index 37b83e3..b01db91 100644 --- a/services/bundlemgr_lite/include/gt_bundle_manager_service.h +++ b/services/bundlemgr_lite/include/gt_bundle_manager_service.h @@ -117,6 +117,7 @@ private: extern "C" { void EnableServiceWdg(void); void DisableServiceWdg(void); +void RefreshAllServiceTimeStamp(void); void SetCurrentBundle(const char *name); const char *GetCurrentBundle(); } diff --git a/services/bundlemgr_lite/include/gt_extractor_util.h b/services/bundlemgr_lite/include/gt_extractor_util.h index 1b1f6c7..cd80804 100644 --- a/services/bundlemgr_lite/include/gt_extractor_util.h +++ b/services/bundlemgr_lite/include/gt_extractor_util.h @@ -36,4 +36,8 @@ private: static bool HasCopiedData(const char *filePath, int32_t fp, uint64_t size); }; } // namespace OHOS + +extern "C" { +void RefreshAllServiceTimeStamp(void); +} #endif // OHOS_GT_BUNDLE_EXTRACTOR_UTIL_H diff --git a/services/bundlemgr_lite/src/bundle_util.cpp b/services/bundlemgr_lite/src/bundle_util.cpp index ae73c7f..6737d8e 100644 --- a/services/bundlemgr_lite/src/bundle_util.cpp +++ b/services/bundlemgr_lite/src/bundle_util.cpp @@ -951,6 +951,9 @@ char *BundleUtil::GetRootDir(const char *dir, int32_t index) bool BundleUtil::CheckDirIsEmpty(const char *dirPath, List* list) { +#ifndef OHOS_APPEXECFWK_BMS_BUNDLEMANAGER + RefreshAllServiceTimeStamp(); +#endif DIR *dir = nullptr; if ((dir = opendir(dirPath)) == nullptr) { return false; diff --git a/services/bundlemgr_lite/src/gt_bundle_installer.cpp b/services/bundlemgr_lite/src/gt_bundle_installer.cpp index 80758aa..b0ad7e2 100644 --- a/services/bundlemgr_lite/src/gt_bundle_installer.cpp +++ b/services/bundlemgr_lite/src/gt_bundle_installer.cpp @@ -68,6 +68,7 @@ uint8_t GtBundleInstaller::PreCheckBundle(const char *path, int32_t &fp, Signatu return errorCode; } + RefreshAllServiceTimeStamp(); errorCode = VerifySignature(path, signatureInfo, fileSize, bundleStyle); if (errorCode != ERR_OK) { UI_Free(bundleName); @@ -244,6 +245,7 @@ uint8_t GtBundleInstaller::ProcessBundleInstall(const char *path, const char *ra (void) GtManagerService::GetInstance().ReportInstallCallback(OPERATION_DOING, 0, BMS_SECOND_FINISHED_PROCESS, installerCallback); // parse HarmoyProfile.json, get permissions and bundleInfo + RefreshAllServiceTimeStamp(); errorCode = GtBundleParser::ParseHapProfile(fp, fileSize, permissions, bundleRes, &bundleInfo); CHECK_PRO_RESULT(errorCode, fp, permissions, bundleInfo, signatureInfo); SetCurrentBundle(bundleInfo->bundleName); @@ -275,6 +277,7 @@ uint8_t GtBundleInstaller::ProcessBundleInstall(const char *path, const char *ra char *tmpCodePath = BundleUtil::Strscat(tmpCodePathComp, sizeof(tmpCodePathComp) / sizeof(char *)); errorCode = (tmpCodePath == nullptr) ? ERR_APPEXECFWK_INSTALL_FAILED_INTERNAL_ERROR : ERR_OK; CHECK_PRO_RESULT(errorCode, fp, permissions, bundleInfo, signatureInfo); + RefreshAllServiceTimeStamp(); errorCode = GtBundleExtractor::ExtractHap(tmpCodePath, installRecord.bundleName, fp, fileSize, bundleStyle); close(fp); CHECK_PRO_PART_ROLLBACK(errorCode, tmpCodePath, permissions, bundleInfo, signatureInfo); @@ -287,6 +290,7 @@ uint8_t GtBundleInstaller::ProcessBundleInstall(const char *path, const char *ra CHECK_PRO_PART_ROLLBACK(errorCode, tmpCodePath, permissions, bundleInfo, signatureInfo); installRecord.jsEngineVersion = jsEngineVersion; // try to transform js file to bc file + RefreshAllServiceTimeStamp(); errorCode = TransformJsToBc(tmpCodePath, installRecord); CHECK_PRO_PART_ROLLBACK(errorCode, tmpCodePath, permissions, bundleInfo, signatureInfo); #endif @@ -297,7 +301,7 @@ uint8_t GtBundleInstaller::ProcessBundleInstall(const char *path, const char *ra errorCode = HandleFileAndBackUpRecord(installRecord, tmpCodePath, randStr, bundleInfo->dataPath, isUpdate); AdapterFree(tmpCodePath); CHECK_PRO_ROLLBACK(errorCode, permissions, bundleInfo, signatureInfo, randStr); - + RefreshAllServiceTimeStamp(); // move rawfile to data path when rawfile is exists errorCode = MoveRawFileToDataPath(bundleInfo); CHECK_PRO_ROLLBACK(errorCode, permissions, bundleInfo, signatureInfo, randStr); diff --git a/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp b/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp index bc76f45..fd9f5da 100644 --- a/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp +++ b/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp @@ -128,10 +128,12 @@ bool GtManagerService::Install(const char *hapPath, const InstallParam *installP (void) ReportInstallCallback(OPERATION_DOING, 0, BMS_INSTALLATION_START, installerCallback); #ifdef _MINI_BMS_PERMISSION_ DisableServiceWdg(); + RefreshAllServiceTimeStamp(); #endif ret = installer_->Install(path, installerCallback); #ifdef _MINI_BMS_PERMISSION_ EnableServiceWdg(); + RefreshAllServiceTimeStamp(); #endif HILOG_INFO(HILOG_MODULE_AAFWK, "[BMS] Install ret is %d", ret); if (ret == 0) { @@ -173,10 +175,12 @@ bool GtManagerService::Uninstall(const char *bundleName, const InstallParam *ins BMS_UNINSTALLATION_START, installerCallback); #ifdef _MINI_BMS_PERMISSION_ DisableServiceWdg(); + RefreshAllServiceTimeStamp(); #endif uint8_t ret = installer_->Uninstall(innerBundleName); #ifdef _MINI_BMS_PERMISSION_ EnableServiceWdg(); + RefreshAllServiceTimeStamp(); #endif HILOG_INFO(HILOG_MODULE_AAFWK, "[BMS] Uninstall ret is %d", ret); if (ret == 0) { @@ -315,6 +319,7 @@ void GtManagerService::InstallPreBundle(List systemPathList, // scan system apps and third system apps #ifdef _MINI_BMS_PERMISSION_ DisableServiceWdg(); + RefreshAllServiceTimeStamp(); #endif ScanSystemApp(uninstallRecord, &systemPathList_); if (uninstallRecord != nullptr) { @@ -325,6 +330,7 @@ void GtManagerService::InstallPreBundle(List systemPathList, ScanThirdApp(INSTALL_PATH, &systemPathList_); #ifdef _MINI_BMS_PERMISSION_ EnableServiceWdg(); + RefreshAllServiceTimeStamp(); #endif for (auto node = systemPathList.Begin(); node != systemPathList.End(); node = node->next_) { ToBeInstalledApp *toBeInstalledApp = node->value_; @@ -338,6 +344,7 @@ void GtManagerService::InstallPreBundle(List systemPathList, toBeInstalledApp->isSystemApp); } (void) Install(toBeInstalledApp->path, nullptr, installerCallback); + RefreshAllServiceTimeStamp(); } RemoveSystemAppPathList(&systemPathList); } @@ -638,6 +645,7 @@ void GtManagerService::ReloadEntireBundleInfo(const char *appPath, const char *b APP_ERRCODE_EXTRA(EXCE_ACE_APP_SCAN, EXCE_ACE_APP_SCAN_PARSE_JSON_FALIED); AdapterFree(appId); AdapterFree(codePath); + BundleUtil::RemoveDir(appPath); return; } } diff --git a/services/bundlemgr_lite/src/gt_extractor_util.cpp b/services/bundlemgr_lite/src/gt_extractor_util.cpp index 13b167a..cd4d622 100644 --- a/services/bundlemgr_lite/src/gt_extractor_util.cpp +++ b/services/bundlemgr_lite/src/gt_extractor_util.cpp @@ -117,6 +117,7 @@ uint8_t GtExtractorUtil::ExtractFileHeaderInfo(int32_t fp, char **bundleName) uint8_t GtExtractorUtil::ExtractFileToPath(const char *appInstallPath, int32_t fp, uint64_t &fileSize, char **fileName, char **relativeFilePath) { + RefreshAllServiceTimeStamp(); uint8_t errorCode = ExtractFileAttr(fp, fileName, relativeFilePath, fileSize); if (errorCode != ERR_OK) { return errorCode; -- Gitee