From 08facc7987645b39b22fe03df6f94c34e4315d8c Mon Sep 17 00:00:00 2001 From: z30054037 Date: Wed, 18 Oct 2023 11:22:47 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: z30054037 Change-Id: I478904d680f9588c0a0dca4ee651a69d383219e1 --- frameworks/js/backup_ext/ext_backup_impl.cpp | 2 +- frameworks/native/backup_ext/src/ext_backup_js.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frameworks/js/backup_ext/ext_backup_impl.cpp b/frameworks/js/backup_ext/ext_backup_impl.cpp index 092bc8cfa..9f6b828b5 100644 --- a/frameworks/js/backup_ext/ext_backup_impl.cpp +++ b/frameworks/js/backup_ext/ext_backup_impl.cpp @@ -21,8 +21,8 @@ extern const char _binary_backup_extension_ability_abc_start[]; extern const char _binary_backup_extension_ability_abc_end[]; static napi_module _module = { - .nm_modname = "application.BackupExtensionAbility", .nm_filename = "application/libbackupextensionability_napi.so/BackupExtensionAbility.js", + .nm_modname = "application.BackupExtensionAbility", }; extern "C" __attribute__((constructor)) void NAPI_application_BackupExtensionAbility_AutoRegister() diff --git a/frameworks/native/backup_ext/src/ext_backup_js.cpp b/frameworks/native/backup_ext/src/ext_backup_js.cpp index 4905d2ce6..ad919e7a9 100644 --- a/frameworks/native/backup_ext/src/ext_backup_js.cpp +++ b/frameworks/native/backup_ext/src/ext_backup_js.cpp @@ -300,7 +300,7 @@ static int DoCallJsMethod(CallJsParam *param) } AbilityRuntime::HandleEscape handleEscape(*jsRuntime); auto env = jsRuntime->GetNapiEnv(); - vector argv = {}; + vector argv; if (param->argParser != nullptr) { if (!param->argParser(env, argv)) { HILOGE("failed to get params."); @@ -318,7 +318,7 @@ static int DoCallJsMethod(CallJsParam *param) HILOGE("ResultValueParser must not null."); return EINVAL; } - napi_value result; + napi_value result = nullptr; napi_call_function(env, value, method, argv.size(), argv.data(), &result); if (!param->retParser(env, handleEscape.Escape(result))) { HILOGI("Parser js result fail."); -- Gitee From cf9c03feee8b7173daa798fb27df02067698c620 Mon Sep 17 00:00:00 2001 From: z30054037 Date: Thu, 19 Oct 2023 03:18:49 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=E5=A4=87=E4=BB=BD=E6=81=A2=E5=A4=8D?= =?UTF-8?q?=E8=B6=85=E6=97=B6=E6=97=B6=E9=97=B4=E9=80=BB=E8=BE=91=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: z30054037 Change-Id: I6da039a512d363027056defee1a167213809f05b --- .../include/module_ipc/svc_session_manager.h | 18 +++++++++++++ services/backup_sa/src/module_ipc/service.cpp | 2 ++ .../src/module_ipc/svc_session_manager.cpp | 25 +++++++++++++++++-- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/services/backup_sa/include/module_ipc/svc_session_manager.h b/services/backup_sa/include/module_ipc/svc_session_manager.h index 59509266e..a342c97a4 100644 --- a/services/backup_sa/include/module_ipc/svc_session_manager.h +++ b/services/backup_sa/include/module_ipc/svc_session_manager.h @@ -58,6 +58,8 @@ struct BackupExtInfo { uint32_t extTimerId; /* Timer Status: true is start & false is stop */ bool timerStatus {false}; + /* Need backup data size */ + int64_t dataSize; }; class Service; @@ -359,6 +361,22 @@ public: */ std::string GetBundleVersionName(const std::string &bundleName); + /** + * @brief Set the bundle data size object + * + * @param bundleName + * @param dataSize + */ + void SetBundleDataSize(const std::string &bundleName, int64_t dataSize); + + /** + * @brief Get the bundle data size object + * + * @param bundleName + * @return dataSize + */ + int64_t GetBundleDataSize(const std::string &bundleName); + /** * @brief 启动应用扩展能力定时器 * diff --git a/services/backup_sa/src/module_ipc/service.cpp b/services/backup_sa/src/module_ipc/service.cpp index 1252a8173..b17ef871e 100644 --- a/services/backup_sa/src/module_ipc/service.cpp +++ b/services/backup_sa/src/module_ipc/service.cpp @@ -257,6 +257,7 @@ ErrCode Service::AppendBundlesRestoreSession(UniqueFd fd, session_->SetBundleRestoreType(bundleInfo.name, restoreType); session_->SetBundleVersionCode(bundleInfo.name, bundleInfo.versionCode); session_->SetBundleVersionName(bundleInfo.name, bundleInfo.versionName); + session_->SetBundleDataSize(bundleInfo.name, bundleInfo.spaceOccupied); } } for (auto info : restoreInfos) { @@ -279,6 +280,7 @@ ErrCode Service::AppendBundlesBackupSession(const vector &bundleName auto backupInfos = BundleMgrAdapter::GetBundleInfos(bundleNames, session_->GetSessionUserId()); session_->AppendBundles(bundleNames); for (auto info : backupInfos) { + session_->SetBundleDataSize(info.name, info.spaceOccupied); if (info.allToBackup == false) { session_->GetServiceReverseProxy()->BackupOnBundleStarted(BError(BError::Codes::SA_REFUSED_ACT), info.name); session_->RemoveExtInfo(info.name); diff --git a/services/backup_sa/src/module_ipc/svc_session_manager.cpp b/services/backup_sa/src/module_ipc/svc_session_manager.cpp index f4ec832fb..e6d8b6596 100644 --- a/services/backup_sa/src/module_ipc/svc_session_manager.cpp +++ b/services/backup_sa/src/module_ipc/svc_session_manager.cpp @@ -568,6 +568,28 @@ std::string SvcSessionManager::GetBundleVersionName(const std::string &bundleNam return it->second.versionName; } +void SvcSessionManager::SetBundleDataSize(const std::string &bundleName, int64_t dataSize) +{ + unique_lock lock(lock_); + if (!impl_.clientToken) { + throw BError(BError::Codes::SA_INVAL_ARG, "No caller token was specified"); + } + + auto it = GetBackupExtNameMap(bundleName); + it->second.dataSize = dataSize; +} + +int64_t SvcSessionManager::GetBundleDataSize(const std::string &bundleName) +{ + unique_lock lock(lock_); + if (!impl_.clientToken) { + throw BError(BError::Codes::SA_INVAL_ARG, "No caller token was specified"); + } + + auto it = GetBackupExtNameMap(bundleName); + return it->second.dataSize; +} + uint32_t SvcSessionManager::CalAppProcessTime(const std::string &bundleName) { const uint32_t defaultTimeout = 30; /* 30 second */ @@ -578,8 +600,7 @@ uint32_t SvcSessionManager::CalAppProcessTime(const std::string &bundleName) uint32_t timeout; try { - stat = StorageMgrAdapter::GetBundleStats(bundleName); - uint64_t appSize = static_cast(stat.appSize_ + stat.dataSize_); + uint64_t appSize = static_cast (GetBundleDataSize(bundleName)); /* % UINT_MAX force conver uint64 to uint32 */ /* timeout = (AppSize / 3Ms) * 3 + 30 */ timeout = (uint32_t)(defaultTimeout + (appSize / processRate) * multiple % UINT_MAX); -- Gitee