diff --git a/frameworks/ets/ani/service_extension_ability/src/ets_service_extension.cpp b/frameworks/ets/ani/service_extension_ability/src/ets_service_extension.cpp index dc2113b4a1..009d8c7b24 100644 --- a/frameworks/ets/ani/service_extension_ability/src/ets_service_extension.cpp +++ b/frameworks/ets/ani/service_extension_ability/src/ets_service_extension.cpp @@ -516,20 +516,48 @@ bool EtsServiceExtension::HandleInsightIntent(const AAFwk::Want &want) }; callback->Push(asyncCallback); InsightIntentExecutorInfo executorInfo; - ret = GetInsightIntentExecutorInfo(want, executeParam, executorInfo); - if (!ret) { - TAG_LOGE(AAFwkTag::SERVICE_EXT, "Get Intent executor failed"); - InsightIntentExecutorMgr::TriggerCallbackInner(std::move(callback), - static_cast(AbilityErrorCode::ERROR_CODE_INVALID_PARAM)); - return false; + const WantParams &wantParams = want.GetParams(); + std::string arkTSMode = wantParams.GetStringParam(AppExecFwk::INSIGHT_INTENT_ARKTS_MODE); + if (arkTSMode == AbilityRuntime::CODE_LANGUAGE_ARKTS_1_2) { + ret = GetInsightIntentExecutorInfo(want, executeParam, executorInfo); + if (!ret) { + TAG_LOGE(AAFwkTag::SERVICE_EXT, "Get Intent executor failed"); + InsightIntentExecutorMgr::TriggerCallbackInner(std::move(callback), + static_cast(AbilityErrorCode::ERROR_CODE_INVALID_PARAM)); + return false; + } + ret = DelayedSingleton::GetInstance()->ExecuteInsightIntent( + etsRuntime_, executorInfo, std::move(callback)); + if (!ret) { + TAG_LOGE(AAFwkTag::SERVICE_EXT, "Execute insight intent failed"); + return false; + } + return true; + } else { + auto& jsRuntime = etsRuntime_.GetJsRuntime(); + if (jsRuntime == nullptr) { + TAG_LOGE(AAFwkTag::UIABILITY, "null jsRuntime"); + return false; + } + if (abilityInfo_) { + auto &jsRuntimePoint = (static_cast(*jsRuntime)); + jsRuntimePoint.UpdateModuleNameAndAssetPath(abilityInfo_->moduleName); + } + ret = GetInsightIntentExecutorInfo(want, executeParam, executorInfo); + if (!ret) { + TAG_LOGE(AAFwkTag::SERVICE_EXT, "Get Intent executor failed"); + InsightIntentExecutorMgr::TriggerCallbackInner(std::move(callback), + static_cast(AbilityErrorCode::ERROR_CODE_INVALID_PARAM)); + return false; + } + ret = DelayedSingleton::GetInstance()->ExecuteInsightIntent( + *jsRuntime, executorInfo, std::move(callback)); + if (!ret) { + TAG_LOGE(AAFwkTag::SERVICE_EXT, "Execute insight intent failed"); + return false; + } + return true; } - ret = DelayedSingleton::GetInstance()->ExecuteInsightIntent( - etsRuntime_, executorInfo, std::move(callback)); - if (!ret) { - TAG_LOGE(AAFwkTag::SERVICE_EXT, "Execute insight intent failed"); - return false; - } - return true; } ani_ref EtsServiceExtension::CallObjectMethod(bool withResult, const char *name, const char *signature, ...) diff --git a/frameworks/ets/ani/ui_ability/src/ets_ui_ability.cpp b/frameworks/ets/ani/ui_ability/src/ets_ui_ability.cpp index 8492e7b7cc..ed76826dd6 100644 --- a/frameworks/ets/ani/ui_ability/src/ets_ui_ability.cpp +++ b/frameworks/ets/ani/ui_ability/src/ets_ui_ability.cpp @@ -1089,20 +1089,48 @@ void EtsUIAbility::ExecuteInsightIntentBackground(const Want &want, if (abilityInfo_) { } + const WantParams &wantParams = want.GetParams(); + std::string arkTSMode = wantParams.GetStringParam(AppExecFwk::INSIGHT_INTENT_ARKTS_MODE); InsightIntentExecutorInfo executeInfo; - auto ret = GetInsightIntentExecutorInfo(want, executeParam, executeInfo); - if (!ret) { - TAG_LOGE(AAFwkTag::UIABILITY, "get intentExecutor failed"); - InsightIntentExecutorMgr::TriggerCallbackInner( - std::move(callback), static_cast(AbilityErrorCode::ERROR_CODE_INVALID_PARAM)); - return; - } + if (arkTSMode == AbilityRuntime::CODE_LANGUAGE_ARKTS_1_2) { + auto ret = GetInsightIntentExecutorInfo(want, executeParam, executeInfo, arkTSMode); + if (!ret) { + TAG_LOGE(AAFwkTag::UIABILITY, "get intentExecutor failed"); + InsightIntentExecutorMgr::TriggerCallbackInner( + std::move(callback), static_cast(AbilityErrorCode::ERROR_CODE_INVALID_PARAM)); + return; + } - ret = DelayedSingleton::GetInstance()->ExecuteInsightIntent( - etsRuntime_, executeInfo, std::move(callback)); - if (!ret) { - // callback has removed, release in insight intent executor. - TAG_LOGE(AAFwkTag::UIABILITY, "execute insightIntent failed"); + ret = DelayedSingleton::GetInstance()->ExecuteInsightIntent( + etsRuntime_, executeInfo, std::move(callback)); + if (!ret) { + // callback has removed, release in insight intent executor. + TAG_LOGE(AAFwkTag::UIABILITY, "execute insightIntent failed"); + } + } else { + auto& jsRuntime = etsRuntime_.GetJsRuntime(); + if (jsRuntime == nullptr) { + TAG_LOGE(AAFwkTag::UIABILITY, "null jsRuntime"); + return; + } + if (abilityInfo_) { + auto &jsRuntimePoint = (static_cast(*jsRuntime)); + jsRuntimePoint.UpdateModuleNameAndAssetPath(abilityInfo_->moduleName); + } + auto ret = GetInsightIntentExecutorInfo(want, executeParam, executeInfo, arkTSMode); + if (!ret) { + TAG_LOGE(AAFwkTag::UIABILITY, "get intentExecutor failed"); + InsightIntentExecutorMgr::TriggerCallbackInner( + std::move(callback), static_cast(AbilityErrorCode::ERROR_CODE_INVALID_PARAM)); + return; + } + + ret = DelayedSingleton::GetInstance()->ExecuteInsightIntent( + *jsRuntime, executeInfo, std::move(callback)); + if (!ret) { + // callback has removed, release in insight intent executor. + TAG_LOGE(AAFwkTag::UIABILITY, "execute insightIntent failed"); + } } }