From 923d4404daf97ce0ead424ea9aaf23f874b782a9 Mon Sep 17 00:00:00 2001 From: "zhangyafei.echo" Date: Sat, 15 Jun 2024 22:09:00 +0800 Subject: [PATCH] bugfix of insight intent. Sig:SIG_ApplicationFramework Feature or BugFix: Feature Binary Source: No Signed-off-by: zhangyafei.echo Change-Id: I2876722af8bf8604cfb837c7141176a097da2789 --- .../napi_common_execute_result.cpp | 38 ++++++++++--------- .../insight_intent_executor.js | 18 ++++++++- 2 files changed, 36 insertions(+), 20 deletions(-) diff --git a/frameworks/js/napi/inner/napi_common/napi_common_execute_result.cpp b/frameworks/js/napi/inner/napi_common/napi_common_execute_result.cpp index 8f1c3c1f7a4..1d4c34668bc 100644 --- a/frameworks/js/napi/inner/napi_common/napi_common_execute_result.cpp +++ b/frameworks/js/napi/inner/napi_common/napi_common_execute_result.cpp @@ -41,25 +41,27 @@ bool UnwrapExecuteResult(napi_env env, napi_value param, InsightIntentExecuteRes } executeResult.code = code; - napi_value result = nullptr; - napi_get_named_property(env, param, "result", &result); - if (result != nullptr) { - napi_valuetype valueType = napi_undefined; - napi_typeof(env, result, &valueType); - if (valueType != napi_object) { - TAG_LOGE(AAFwkTag::JSNAPI, "Wrong argument type result."); - return false; + if (IsExistsByPropertyName(env, param, "result")) { + napi_value result = nullptr; + napi_get_named_property(env, param, "result", &result); + if (result != nullptr) { + napi_valuetype valueType = napi_undefined; + napi_typeof(env, result, &valueType); + if (valueType != napi_object) { + TAG_LOGE(AAFwkTag::JSNAPI, "Wrong argument type result."); + return false; + } + auto wp = std::make_shared(); + if (!AppExecFwk::UnwrapWantParams(env, result, *wp)) { + TAG_LOGE(AAFwkTag::JSNAPI, "Wrong argument type result."); + return false; + } + if (!executeResult.CheckResult(wp)) { + TAG_LOGE(AAFwkTag::JSNAPI, "Invalid intent result."); + return false; + } + executeResult.result = wp; } - auto wp = std::make_shared(); - if (!AppExecFwk::UnwrapWantParams(env, result, *wp)) { - TAG_LOGE(AAFwkTag::JSNAPI, "Wrong argument type result."); - return false; - } - if (!executeResult.CheckResult(wp)) { - TAG_LOGE(AAFwkTag::JSNAPI, "Invalid intent result."); - return false; - } - executeResult.result = wp; } return true; diff --git a/frameworks/js/napi/insight_intent/insight_intent_executor/insight_intent_executor.js b/frameworks/js/napi/insight_intent/insight_intent_executor/insight_intent_executor.js index c9b0966f7b1..2f5c9934f70 100644 --- a/frameworks/js/napi/insight_intent/insight_intent_executor/insight_intent_executor.js +++ b/frameworks/js/napi/insight_intent/insight_intent_executor/insight_intent_executor.js @@ -17,14 +17,28 @@ class InsightIntentExecutor { constructor() {} onExecuteInUIAbilityForegroundMode(name, param, pageLoader) { - console.log(`onExecuteInUIAbilityForegroundMode $name$`); + console.log(`onExecuteInUIAbilityForegroundMode ${name}`); return { 'code': 0 }; } onExecuteInUIAbilityBackgroundMode(name, param) { - console.log(`onExecuteInUIAbilityForegroundMode $name$`); + console.log(`onExecuteInUIAbilityForegroundMode ${name}`); + return { + 'code': 0 + }; + } + + onExecuteInUIExtensionAbility(name, param, pageLoader) { + console.log(`onExecuteInUIExtensionAbility ${name}`); + return { + 'code': 0 + }; + } + + onExecuteInServiceExtensionAbility(name, param) { + console.log(`onExecuteInServiceExtensionAbility ${name}`); return { 'code': 0 }; -- Gitee