diff --git a/services/backup_sa/include/module_external/bms_adapter.h b/services/backup_sa/include/module_external/bms_adapter.h index af1c849e412b84516b18ad76006b633cf9548466..9903ec49819016f24a4487f1a1fc747c60782d9c 100644 --- a/services/backup_sa/include/module_external/bms_adapter.h +++ b/services/backup_sa/include/module_external/bms_adapter.h @@ -61,6 +61,8 @@ public: */ static std::vector GetBundleInfosForIncremental( const std::vector &incrementalDataList, int32_t userId); + + static std::vector GetBundleInfosForIncremental(int32_t userId); }; } // namespace OHOS::FileManagement::Backup #endif // OHOS_FILEMGMT_BACKUP_BUNDLE_MGR_ADAPTER_H diff --git a/services/backup_sa/src/module_external/bms_adapter.cpp b/services/backup_sa/src/module_external/bms_adapter.cpp index d0753183da328ebe2e2b24ef3f723ea54eafc5e8..d42fa0698de2fdb7bd8d7074455fed489bcf4240 100644 --- a/services/backup_sa/src/module_external/bms_adapter.cpp +++ b/services/backup_sa/src/module_external/bms_adapter.cpp @@ -314,4 +314,36 @@ vector BundleMgrAdapter::GetBundleInfosForIncrement HILOGI("BundleMgrAdapter GetBundleInfosForIncremental end "); return newBundleInfos; } + +vector BundleMgrAdapter::GetBundleInfosForIncremental(int32_t userId) +{ + vector bundleNames; + vector bundleInfos; + vector installedBundles; + auto bms = GetBundleManager(); + if (!bms->GetBundleInfos(AppExecFwk::GET_BUNDLE_WITH_EXTENSION_INFO, installedBundles, userId)) { + throw BError(BError::Codes::SA_BROKEN_IPC, "Failed to get bundle infos"); + } + for (auto const &installedBundle : installedBundles) { + if (installedBundle.applicationInfo.codePath == HMOS_HAP_CODE_PATH || + installedBundle.applicationInfo.codePath == LINUX_HAP_CODE_PATH) { + HILOGI("Unsupported applications, name : %{public}s", installedBundle.name.data()); + continue; + } + auto [allToBackup, extName, restoreDeps, supportScene] = GetAllowAndExtName(installedBundle.extensionInfos); + int64_t dataSize = 0; + if (!allToBackup) { + bundleInfos.emplace_back(BJsonEntityCaps::BundleInfo {installedBundle.name, installedBundle.versionCode, + installedBundle.versionName, dataSize, allToBackup, + extName, restoreDeps, supportScene}); + } else { + bundleNames.emplace_back(BIncrementalData {installedBundle.name, 0}); + } + } + auto bundleInfosNew = BundleMgrAdapter::GetBundleInfosForIncremental(bundleNames, userId); + for(auto &bundleInfo : bundleInfosNew) { + bundleInfos.emplace_back(bundleInfo); + } + return bundleInfos; +} } // namespace OHOS::FileManagement::Backup diff --git a/services/backup_sa/src/module_ipc/service.cpp b/services/backup_sa/src/module_ipc/service.cpp index 18a2f76d33bd0c3355189ee234d7df72a60dc740..339c2a9172e975c72ffb9b3588a32fa62978c3df 100644 --- a/services/backup_sa/src/module_ipc/service.cpp +++ b/services/backup_sa/src/module_ipc/service.cpp @@ -121,7 +121,7 @@ UniqueFd Service::GetLocalCapabilities() cache.SetSystemFullName(GetOSFullName()); cache.SetDeviceType(GetDeviceType()); - auto bundleInfos = BundleMgrAdapter::GetBundleInfos(session_->GetSessionUserId()); + auto bundleInfos = BundleMgrAdapter::GetBundleInfosForIncremental(session_->GetSessionUserId()); cache.SetBundleInfos(bundleInfos); cachedEntity.Persist(); session_->DecreaseSessionCnt();