From dfc0f60b1db5135e038ec3c7205fb958b4ae7abb Mon Sep 17 00:00:00 2001 From: zheng_zhi_hao Date: Thu, 24 Oct 2024 22:33:00 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=80=E5=87=BA=E6=89=80=E6=9C=89=E6=8B=93?= =?UTF-8?q?=E5=B1=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zheng_zhi_hao --- frameworks/ohscan/src/ohscan.cpp | 2 +- .../kits/napi/print_napi/include/print_task.h | 2 +- .../kits/napi/print_napi/src/print_task.cpp | 16 ++++++++++------ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/frameworks/ohscan/src/ohscan.cpp b/frameworks/ohscan/src/ohscan.cpp index f64f64c..ac2d85b 100644 --- a/frameworks/ohscan/src/ohscan.cpp +++ b/frameworks/ohscan/src/ohscan.cpp @@ -249,7 +249,7 @@ bool MemSetScannerOptions(Scan_ScannerOptions* scannerOptions, int32_t &optionCo { for (int i = 0; i < optionCount; i++) { auto bufferSize = paraTable.titBuff[i].length() + 1; - char* titBuff = new(std::nothrow) char[bufferSize]; + char* titBuff = new (std::nothrow) char[bufferSize]; if (!CopySingleBuf(titBuff, paraTable.titBuff[i].c_str(), bufferSize)) { if (titBuff != nullptr) { delete[] titBuff; diff --git a/interfaces/kits/napi/print_napi/include/print_task.h b/interfaces/kits/napi/print_napi/include/print_task.h index cae7cca..8984a21 100644 --- a/interfaces/kits/napi/print_napi/include/print_task.h +++ b/interfaces/kits/napi/print_napi/include/print_task.h @@ -60,7 +60,7 @@ private: bool ParseAbilityContextReq(napi_env env, const napi_value &obj, std::shared_ptr &abilityContext, std::shared_ptr &uiExtensionContext); - void StartUIExtensionAbility( + uint32_t StartUIExtensionAbility( std::shared_ptr asyncContext, const std::shared_ptr &adapterParam); uint32_t StartUIExtensionAbility(OHOS::AAFwk::Want &want, std::shared_ptr asyncContext); OHOS::Ace::UIContent* GetUIContent(const BaseContext *asyncContext); diff --git a/interfaces/kits/napi/print_napi/src/print_task.cpp b/interfaces/kits/napi/print_napi/src/print_task.cpp index 1ef734d..8bbd00d 100644 --- a/interfaces/kits/napi/print_napi/src/print_task.cpp +++ b/interfaces/kits/napi/print_napi/src/print_task.cpp @@ -198,7 +198,11 @@ uint32_t PrintTask::CallSpooler( PRINT_CALL_BASE(env, napi_create_promise(env, &asyncContext->deferred, &result), E_PRINT_INVALID_PARAMETER); PRINT_HILOGD("is a promise api"); } - StartUIExtensionAbility(asyncContext, adapterParam); + uint32_t ret = StartUIExtensionAbility(asyncContext, adapterParam); + if (ret != E_PRINT_NONE) { + PRINT_HILOGE("StartUIExtensionAbility fail"); + return ret; + } PRINT_HILOGI("end CallSpooler"); return E_PRINT_NONE; } @@ -236,18 +240,18 @@ bool PrintTask::ParseAbilityContextReq(napi_env env, const napi_value &obj, return true; } -void PrintTask::StartUIExtensionAbility( +uint32_t PrintTask::StartUIExtensionAbility( std::shared_ptr asyncContext, const std::shared_ptr &adapterParam) { PRINT_HILOGD("begin StartUIExtensionAbility"); if (adapterParam == nullptr) { PRINT_HILOGE("adapterParam is nullptr."); - return; + return E_PRINT_INVALID_PARAMETER; } if ((adapterParam->isCheckFdList && fileList_.empty() && fdList_.empty())) { PRINT_HILOGE("to be printed filelist and fdlist are empty."); - return; + return E_PRINT_INVALID_PARAMETER; } AAFwk::Want want; want.SetElementName(SPOOLER_BUNDLE_NAME, SPOOLER_PREVIEW_ABILITY_NAME); @@ -266,9 +270,9 @@ void PrintTask::StartUIExtensionAbility( want.SetParam(ABILITY_PARAMS_STREAM, fileList_); want.SetFlags(AAFwk::Want::FLAG_AUTH_READ_URI_PERMISSION); - StartUIExtensionAbility(want, asyncContext); + uint32_t ret = StartUIExtensionAbility(want, asyncContext); PRINT_HILOGD("end StartUIExtensionAbility"); - return; + return ret; } uint32_t PrintTask::StartUIExtensionAbility(OHOS::AAFwk::Want &want, std::shared_ptr asyncContext)