diff --git a/frameworks/native/backup_kit_inner/src/b_incremental_session_restore_async.cpp b/frameworks/native/backup_kit_inner/src/b_incremental_session_restore_async.cpp index c531d37d9e55b5c95237048290cdd65689d648a8..248726f22cf5dae4af139d006d0d188e9f8b7e64 100644 --- a/frameworks/native/backup_kit_inner/src/b_incremental_session_restore_async.cpp +++ b/frameworks/native/backup_kit_inner/src/b_incremental_session_restore_async.cpp @@ -27,7 +27,7 @@ using namespace std; BIncrementalSessionRestoreAsync::~BIncrementalSessionRestoreAsync() { if (!deathRecipient_) { - HILOGI("Death Recipient is nullptr"); + HILOGE("Death Recipient is nullptr"); return; } auto proxy = ServiceProxy::GetInstance(); @@ -49,7 +49,7 @@ shared_ptr BIncrementalSessionRestoreAsync::Ini ServiceProxy::InvaildInstance(); auto proxy = ServiceProxy::GetInstance(); if (proxy == nullptr) { - HILOGI("Failed to get backup service"); + HILOGE("Failed to get backup service"); return nullptr; } BIncrementalRestoreSession::Callbacks callbacksTmp {.onFileReady = callbacks.onFileReady, diff --git a/services/backup_sa/include/module_external/bms_adapter.h b/services/backup_sa/include/module_external/bms_adapter.h index 9903ec49819016f24a4487f1a1fc747c60782d9c..4603c38fd1cdf5c50543109371f31a78997e485f 100644 --- a/services/backup_sa/include/module_external/bms_adapter.h +++ b/services/backup_sa/include/module_external/bms_adapter.h @@ -29,13 +29,6 @@ class InnerReceiverImpl; class BundleMgrAdapter { public: - /** - * @brief Get the Bundle Infos object - * - * @param userId User ID - * @return std::vector - */ - static std::vector GetBundleInfos(int32_t userId); /** * @brief Get the bundle infos object diff --git a/services/backup_sa/src/module_external/bms_adapter.cpp b/services/backup_sa/src/module_external/bms_adapter.cpp index bb12e66279ecce2169ca27b6e854ec6167469c5f..1ae0c15dbcd1ff2bc6efe611bf615b9f0e2667f5 100644 --- a/services/backup_sa/src/module_external/bms_adapter.cpp +++ b/services/backup_sa/src/module_external/bms_adapter.cpp @@ -106,32 +106,6 @@ static int64_t GetBundleStats(const string &bundleName, int32_t userId) return dataSize_; } -vector BundleMgrAdapter::GetBundleInfos(int32_t userId) -{ - 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) { - dataSize = GetBundleStats(installedBundle.name, userId); - } - bundleInfos.emplace_back(BJsonEntityCaps::BundleInfo {installedBundle.name, installedBundle.versionCode, - installedBundle.versionName, dataSize, allToBackup, - extName, restoreDeps, supportScene}); - } - return bundleInfos; -} - vector BundleMgrAdapter::GetBundleInfos(const vector &bundleNames, int32_t userId) { vector bundleInfos; @@ -317,12 +291,14 @@ vector BundleMgrAdapter::GetBundleInfosForIncrement vector BundleMgrAdapter::GetBundleInfosForIncremental(int32_t userId) { - vector bundleNames; 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"); } + + vector bundleNames; + vector bundleInfos; for (auto const &installedBundle : installedBundles) { if (installedBundle.applicationInfo.codePath == HMOS_HAP_CODE_PATH || installedBundle.applicationInfo.codePath == LINUX_HAP_CODE_PATH) { @@ -330,10 +306,15 @@ vector BundleMgrAdapter::GetBundleInfosForIncrement continue; } auto [allToBackup, extName, restoreDeps, supportScene] = GetAllowAndExtName(installedBundle.extensionInfos); - if (allToBackup) { + if (!allToBackup) { + bundleInfos.emplace_back(BJsonEntityCaps::BundleInfo {installedBundle.name, installedBundle.versionCode, + installedBundle.versionName, 0, allToBackup, extName, restoreDeps, supportScene}); + } else { bundleNames.emplace_back(BIncrementalData {installedBundle.name, 0}); } } - return BundleMgrAdapter::GetBundleInfosForIncremental(bundleNames, userId); + auto bundleInfosNew = BundleMgrAdapter::GetBundleInfosForIncremental(bundleNames, userId); + copy(bundleInfosNew.begin(), bundleInfosNew.end(), back_inserter(bundleInfos)); + return bundleInfos; } } // namespace OHOS::FileManagement::Backup diff --git a/tests/mock/module_external/bms_adapter_mock.cpp b/tests/mock/module_external/bms_adapter_mock.cpp index afff66e3ee8222dfd7c395189bc63a8ffc2ff2a6..602c4f45a6e46abc7f4961faec503697d633a0f0 100644 --- a/tests/mock/module_external/bms_adapter_mock.cpp +++ b/tests/mock/module_external/bms_adapter_mock.cpp @@ -28,14 +28,6 @@ namespace OHOS::FileManagement::Backup { using namespace std; -vector BundleMgrAdapter::GetBundleInfos(int32_t userId) -{ - vector bundleInfos; - bundleInfos.emplace_back( - BJsonEntityCaps::BundleInfo {"com.example.app2backup", {}, {}, 0, true, "com.example.app2backup"}); - return bundleInfos; -} - vector BundleMgrAdapter::GetBundleInfos(const vector &bundleNames, int32_t userId) { vector bundleInfos;