From 9e3fec06ef39bacf59b67e4714363b61003c796a Mon Sep 17 00:00:00 2001 From: libuyan <1014734367@qq.com> Date: Mon, 1 Apr 2024 17:39:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=97=A0=E7=94=A8=E9=94=81?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E6=94=B9napi=E5=9B=9E=E8=B0=83=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: libuyan <1014734367@qq.com> --- frameworks/native/backup_ext/include/ext_extension.h | 2 -- frameworks/native/backup_ext/src/ext_extension.cpp | 8 +------- interfaces/kits/js/backup/session_restore_n_exporter.cpp | 9 +-------- 3 files changed, 2 insertions(+), 17 deletions(-) diff --git a/frameworks/native/backup_ext/include/ext_extension.h b/frameworks/native/backup_ext/include/ext_extension.h index bf47f8744..6cf1ee997 100644 --- a/frameworks/native/backup_ext/include/ext_extension.h +++ b/frameworks/native/backup_ext/include/ext_extension.h @@ -146,8 +146,6 @@ private: std::shared_mutex lock_; std::shared_ptr extension_; std::vector tars_; - std::mutex getExtInfoMtx_; - std::condition_variable getExtInfoCondition_; std::string backupInfo_; OHOS::ThreadPool threadPool_; }; diff --git a/frameworks/native/backup_ext/src/ext_extension.cpp b/frameworks/native/backup_ext/src/ext_extension.cpp index 98e54a135..be60bda58 100644 --- a/frameworks/native/backup_ext/src/ext_extension.cpp +++ b/frameworks/native/backup_ext/src/ext_extension.cpp @@ -69,7 +69,6 @@ using namespace std; namespace { const int64_t DEFAULT_SLICE_SIZE = 100 * 1024 * 1024; // 分片文件大小为100M const uint32_t MAX_FILE_COUNT = 6000; // 单个tar包最多包含6000个文件 -const int32_t CONNECT_WAIT_TIME_S = 15; } // namespace void BackupExtExtension::VerifyCaller() @@ -1587,18 +1586,13 @@ ErrCode BackupExtExtension::GetBackupInfo(std::string &result) auto callBackup = [ptr](std::string result) { HILOGI("GetBackupInfo callBackup start. result = %{public}s", result.c_str()); ptr->backupInfo_ = result; - ptr->getExtInfoCondition_.notify_one(); }; auto ret = ptr->extension_->GetBackupInfo(callBackup); if (ret != ERR_OK) { HILOGE("Failed to notify the app done. err = %{public}d", ret); return BError(BError::Codes::EXT_INVAL_ARG, "extension getBackupInfo exception").GetCode(); } - HILOGD("GetBackupInfo getExtInfoMtx_ lock."); - std::unique_lock lock(getExtInfoMtx_); - getExtInfoCondition_.wait_for(lock, std::chrono::seconds(CONNECT_WAIT_TIME_S)); - HILOGD("GetBackupInfo getExtInfoMtx_ unlock."); - + HILOGD("GetBackupInfo lby, backupInfo = %s", backupInfo_.c_str()); result = backupInfo_; backupInfo_.clear(); diff --git a/interfaces/kits/js/backup/session_restore_n_exporter.cpp b/interfaces/kits/js/backup/session_restore_n_exporter.cpp index a950ca206..2d3d67fe5 100644 --- a/interfaces/kits/js/backup/session_restore_n_exporter.cpp +++ b/interfaces/kits/js/backup/session_restore_n_exporter.cpp @@ -265,14 +265,7 @@ static void onResultReport(weak_ptr pCallbacks, const std::str } auto cbCompl = [result {result}](napi_env env, NError err) -> NVal { - NVal resultStr = NVal::CreateUTF8String(env, result); - NVal res; - napi_status status = napi_set_named_property(env, res.val_, FILEIO_TAG_ERR_DATA.c_str(), resultStr.val_); - if (status != napi_ok) { - HILOGE("Failed to set data property, status %{public}d, bundleName %{public}s", status, result.c_str()); - } - - return res; + return NVal::CreateUTF8String(env, result); }; callbacks->onResultReport.ThreadSafeSchedule(cbCompl);