From 5b115184cd856c1e5437720eadedceac8c780ce0 Mon Sep 17 00:00:00 2001 From: zhuhan Date: Thu, 23 Nov 2023 18:54:51 +0800 Subject: [PATCH] intent const Signed-off-by: zhuhan Change-Id: I6616b2bd458615f6cbf2992cbf2b83389e9f3d39 --- .../ability_constant/ability_constant_module.cpp | 1 + .../native/ability_runtime/js_ui_ability.cpp | 14 ++++++++++---- .../ability_manager/include/launch_param.h | 3 ++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/frameworks/js/napi/ability_constant/ability_constant_module.cpp b/frameworks/js/napi/ability_constant/ability_constant_module.cpp index dee075745e..a8ebd9c32f 100644 --- a/frameworks/js/napi/ability_constant/ability_constant_module.cpp +++ b/frameworks/js/napi/ability_constant/ability_constant_module.cpp @@ -59,6 +59,7 @@ static napi_value InitLaunchReasonObject(napi_env env) NAPI_CALL(env, SetEnumItem(env, object, "APP_RECOVERY", LAUNCHREASON_APP_RECOVERY)); NAPI_CALL(env, SetEnumItem(env, object, "SHARE", LAUNCHREASON_SHARE)); NAPI_CALL(env, SetEnumItem(env, object, "AUTO_STARTUP", LAUNCHREASON_AUTO_STARTUP)); + NAPI_CALL(env, SetEnumItem(env, object, "INSIGHT_INTENT", LAUNCHREASON_INSIGHT_INTENT)); HILOG_DEBUG("end"); return object; diff --git a/frameworks/native/ability/native/ability_runtime/js_ui_ability.cpp b/frameworks/native/ability/native/ability_runtime/js_ui_ability.cpp index 2e0b4632ce..0bd0830b55 100644 --- a/frameworks/native/ability/native/ability_runtime/js_ui_ability.cpp +++ b/frameworks/native/ability/native/ability_runtime/js_ui_ability.cpp @@ -249,10 +249,13 @@ void JsUIAbility::OnStart(const Want &want, sptr sessionInfo napi_set_named_property(env, obj, "launchWant", jsWant); napi_set_named_property(env, obj, "lastRequestWant", jsWant); - + auto launchParam = GetLaunchParam(); + if (InsightIntentExecuteParam::IsInsightIntentExecute(want)) { + launchParam.launchReason = AAFwk::LaunchReason::LAUNCHREASON_INSIGHT_INTENT; + } napi_value argv[] = { jsWant, - CreateJsLaunchParam(env, GetLaunchParam()), + CreateJsLaunchParam(env, launchParam), }; std::string methodName = "OnStart"; AddLifecycleEventBeforeJSCall(FreezeUtil::TimeoutState::FOREGROUND, methodName); @@ -1079,10 +1082,13 @@ void JsUIAbility::OnNewWant(const Want &want) } napi_set_named_property(env, obj, "lastRequestWant", jsWant); - + auto launchParam = GetLaunchParam(); + if (InsightIntentExecuteParam::IsInsightIntentExecute(want)) { + launchParam.launchReason = AAFwk::LaunchReason::LAUNCHREASON_INSIGHT_INTENT; + } napi_value argv[] = { jsWant, - CreateJsLaunchParam(env, GetLaunchParam()), + CreateJsLaunchParam(env, launchParam), }; std::string methodName = "OnNewWant"; AddLifecycleEventBeforeJSCall(FreezeUtil::TimeoutState::FOREGROUND, methodName); diff --git a/interfaces/inner_api/ability_manager/include/launch_param.h b/interfaces/inner_api/ability_manager/include/launch_param.h index 12477a6232..9f44644db4 100644 --- a/interfaces/inner_api/ability_manager/include/launch_param.h +++ b/interfaces/inner_api/ability_manager/include/launch_param.h @@ -33,7 +33,8 @@ enum LaunchReason { LAUNCHREASON_SHARE, LAUNCHREASON_START_EXTENSION, LAUNCHREASON_CONNECT_EXTENSION, - LAUNCHREASON_AUTO_STARTUP + LAUNCHREASON_AUTO_STARTUP, + LAUNCHREASON_INSIGHT_INTENT }; /**