diff --git a/bundle.json b/bundle.json index bd5e1268d1b0c448aff326afd35c448a47677937..1d891d66b1cf53790f0ff77b45eedc77520fb01b 100644 --- a/bundle.json +++ b/bundle.json @@ -102,6 +102,7 @@ "//foundation/ability/ability_runtime/interfaces/inner_api:innerkits_target", "//foundation/ability/ability_runtime/frameworks/native/ability/native:ability_thread", "//foundation/ability/ability_runtime/frameworks/native/ability/native:extension_module", + "//foundation/ability/ability_runtime/frameworks/native/insight_intent:insight_intent_innerkits", "//foundation/ability/ability_runtime/frameworks/js/napi:napi_packages", "//foundation/ability/ability_runtime/js_environment/frameworks/js_environment:js_environment", "//foundation/ability/ability_runtime/services/abilitymgr/etc:appfwk_etc", diff --git a/frameworks/js/napi/BUILD.gn b/frameworks/js/napi/BUILD.gn index 1a4456cb2b2490230faa64d34e538750b11121b7..1e76eaa2de09a1e579ab846595c0ea7c480e8825 100644 --- a/frameworks/js/napi/BUILD.gn +++ b/frameworks/js/napi/BUILD.gn @@ -52,6 +52,7 @@ group("napi_packages") { "${ability_runtime_napi_path}/feature_ability:featureability_napi", "${ability_runtime_napi_path}/inner/napi_ability_common:napi_ability_common", "${ability_runtime_napi_path}/inner/napi_common:napi_common", + "${ability_runtime_napi_path}/insight_intent_context:insightintentcontext_napi", "${ability_runtime_napi_path}/js_child_process:childprocess_napi", "${ability_runtime_napi_path}/js_child_process_manager:childprocessmanager_napi", "${ability_runtime_napi_path}/js_dialog_request:dialogrequest_napi", diff --git a/frameworks/js/napi/insight_intent_context/BUILD.gn b/frameworks/js/napi/insight_intent_context/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..0387dfc3276ae79b98ba9223f30dc5e1f3b19994 --- /dev/null +++ b/frameworks/js/napi/insight_intent_context/BUILD.gn @@ -0,0 +1,50 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/ohos.gni") +import("//foundation/ability/ability_runtime/ability_runtime.gni") + +ohos_shared_library("insightintentcontext_napi") { + include_dirs = [ + "./", + "${ability_runtime_innerkits_path}/insight_intent/insight_intent_context", + "${ability_runtime_path}/interfaces/kits/native/ability/native/ability_business_error", + ] + + sources = [ + "insight_intent_context_module.cpp", + "js_insight_intent_context.cpp", + ] + + defines = [ "AMS_LOG_TAG = \"InsigtIntent\"" ] + defines += [ "AMS_LOG_DOMAIN = 0xD001308" ] + + deps = [ + "${ability_runtime_napi_path}/inner/napi_common:napi_common", + "${ability_runtime_native_path}/ability/native:ability_business_error", + "${ability_runtime_native_path}/insight_intent/insight_intent_context:insightintentcontext", + ] + + external_deps = [ + "ability_base:want", + "c_utils:utils", + "hilog:libhilog", + "hitrace:hitrace_meter", + "ipc:ipc_single", + "napi:ace_napi", + ] + + relative_install_dir = "module/app/ability" + subsystem_name = "ability" + part_name = "ability_runtime" +} diff --git a/frameworks/js/napi/insight_intent_context/insight_intent_context_module.cpp b/frameworks/js/napi/insight_intent_context/insight_intent_context_module.cpp new file mode 100644 index 0000000000000000000000000000000000000000..aa64e92b54796fe0d090b4fee3de61c8e02a5aa3 --- /dev/null +++ b/frameworks/js/napi/insight_intent_context/insight_intent_context_module.cpp @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "napi/native_api.h" + +/* + * The insight intent context module definition. + */ +static napi_module _module = { + .nm_version = 0, + .nm_modname = "app.ability.InsightIntentContext", + .nm_filename = "app/ability/insightintentcontext_napi.so", +}; + +/* + * The insight intent context module registration. + */ +extern "C" __attribute__((constructor)) void NAPI_Insight_Intent_Context_AutoRegister(void) +{ + napi_module_register(&_module); +} diff --git a/frameworks/js/napi/insight_intent_context/js_insight_intent_context.cpp b/frameworks/js/napi/insight_intent_context/js_insight_intent_context.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7a4261858f46bfc29f2d04d3b0cce66cfb9e8a45 --- /dev/null +++ b/frameworks/js/napi/insight_intent_context/js_insight_intent_context.cpp @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "js_insight_intent_context.h" + +#include "ability_window_configuration.h" +#include "hilog_wrapper.h" +#include "hitrace_meter.h" +#include "js_error_utils.h" +#include "napi_common_want.h" + +namespace OHOS { +namespace AbilityRuntime { +namespace { +constexpr static char CONTEXT_MODULE_NAME[] = "InsightIntentContext"; +} + +void JsInsightIntentContext::Finalizer(napi_env env, void* data, void* hint) +{ + HILOG_INFO("enter"); + std::unique_ptr(static_cast(data)); +} + +napi_value JsInsightIntentContext::StartAbiity(napi_env env, napi_callback_info info) +{ + HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); + GET_NAPI_INFO_AND_CALL(env, info, JsInsightIntentContext, OnStartAbility); +} + +napi_value JsInsightIntentContext::OnStartAbility(napi_env env, NapiCallbackInfo& info) +{ + HILOG_DEBUG("enter"); + HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); + if (info.argc == 0) { + HILOG_ERROR("not enough args"); + ThrowTooFewParametersError(env); + return CreateJsUndefined(env); + } + // unwrap want + AAFwk::Want want; + OHOS::AppExecFwk::UnwrapWant(env, info.argv[0], want); + + auto context = context_.lock(); + if (context == nullptr) { + HILOG_ERROR("invalid context"); + ThrowError(env, AbilityErrorCode::ERROR_CODE_INNER); + return CreateJsUndefined(env); + } + + // verify if bundleName is empty or invalid + auto bundleNameFromWant = want.GetElement().GetBundleName(); + if (bundleNameFromWant.empty() || bundleNameFromWant != context->GetBundleName()) { + HILOG_ERROR("bundleName is empty or invalid"); + ThrowError(env, AbilityErrorCode::ERROR_CODE_OPERATION_NOT_SUPPORTED); + return CreateJsUndefined(env); + } + // modify windowmode setting + auto windowMode = context->GetCurrentWindowMode(); + if (windowMode == AAFwk::AbilityWindowConfiguration::MULTI_WINDOW_DISPLAY_PRIMARY || + windowMode == AAFwk::AbilityWindowConfiguration::MULTI_WINDOW_DISPLAY_SECONDARY) { + want.SetParam(AAFwk::Want::PARAM_RESV_WINDOW_MODE, windowMode); + } + + auto innerErrCode = std::make_shared(ERR_OK); + // create execute task + NapiAsyncTask::ExecuteCallback execute = [weak = context_, want, innerErrCode]() { + auto context = weak.lock(); + if (!context) { + HILOG_ERROR("context is released"); + *innerErrCode = static_cast(AbilityErrorCode::ERROR_CODE_INVALID_CONTEXT); + return; + } + *innerErrCode = context->StartAbilityByInsightIntent(want); + }; + // create complete task + NapiAsyncTask::CompleteCallback complete = [innerErrCode](napi_env env, NapiAsyncTask& task, int32_t status) { + if (*innerErrCode == ERR_OK) { + HILOG_DEBUG("StartAbility success."); + task.Resolve(env, CreateJsUndefined(env)); + } else { + task.Reject(env, CreateJsErrorByNativeErr(env, *innerErrCode)); + } + }; + + napi_value lastParam = (info.argc > 1) ? info.argv[1] : nullptr; + napi_value result = nullptr; + NapiAsyncTask::ScheduleHighQos("JsInsightIntentContext::OnStartAbility", env, + CreateAsyncTaskWithLastParam(env, lastParam, std::move(execute), std::move(complete), &result)); + HILOG_DEBUG("end"); + return result; +} + +napi_value CreateJsInsightIntentContext(napi_env env, const std::shared_ptr& context) +{ + HILOG_DEBUG("enter"); + napi_value contextObj; + napi_create_object(env, &contextObj); + + std::unique_ptr jsInsightIntentContext = std::make_unique(context); + napi_wrap(env, contextObj, jsInsightIntentContext.release(), JsInsightIntentContext::Finalizer, nullptr, nullptr); + + BindNativeFunction(env, contextObj, "startAbility", CONTEXT_MODULE_NAME, JsInsightIntentContext::StartAbiity); + HILOG_DEBUG("end"); + return contextObj; +} +} // namespace AbilityRuntime +} // namespace OHOS diff --git a/frameworks/js/napi/insight_intent_context/js_insight_intent_context.h b/frameworks/js/napi/insight_intent_context/js_insight_intent_context.h new file mode 100644 index 0000000000000000000000000000000000000000..f3ee43064c48fa83b8cc0515b3b042814be04987 --- /dev/null +++ b/frameworks/js/napi/insight_intent_context/js_insight_intent_context.h @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ABILITY_RUNTIME_JS_INSIGHT_INTENT_CONTEXT_H +#define OHOS_ABILITY_RUNTIME_JS_INSIGHT_INTENT_CONTEXT_H + +#include "native_engine/native_engine.h" +#include "insight_intent_context.h" +#include "js_runtime_utils.h" + +namespace OHOS { +namespace AbilityRuntime { +/** + * @class JsInsightIntentContext + * JsInsightIntentContext provides a context for insightintent to execute certain tasks. + */ +class JsInsightIntentContext final { +public: + explicit JsInsightIntentContext(const std::shared_ptr& context) : context_(context) {} + ~JsInsightIntentContext() = default; + + static void Finalizer(napi_env env, void* data, void* hint); + + /** + * Starts a new ability. Only such ability in the same application with the caller + * can be started. + * + * @param env, the napi environment. + * @param info, the params passed from js caller. + * + * @return result of StartAbility. + */ + static napi_value StartAbiity(napi_env env, napi_callback_info info); + +private: + napi_value OnStartAbility(napi_env env, NapiCallbackInfo& info); + + std::weak_ptr context_; +}; + +/** + * Creates an js object for specific insight intent context. + * + * @param env, the napi environment. + * @param context, the specific insight intent context object. + * + * @return result of StartAbility. + */ +napi_value CreateJsInsightIntentContext(napi_env env, const std::shared_ptr& context); + +} // namespace AbilityRuntime +} // namespace OHOS +#endif // OHOS_ABILITY_RUNTIME_JS_INSIGHT_INTENT_CONTEXT_H diff --git a/frameworks/native/ability/native/ability_business_error/ability_business_error.cpp b/frameworks/native/ability/native/ability_business_error/ability_business_error.cpp old mode 100755 new mode 100644 index 987807aa8b3f6d0faaa859516d9e8819d16f4519..3b9ca20c228443e3729434ebbeeea9d3addb9bd9 --- a/frameworks/native/ability/native/ability_business_error/ability_business_error.cpp +++ b/frameworks/native/ability/native/ability_business_error/ability_business_error.cpp @@ -140,7 +140,8 @@ static std::unordered_map INNER_TO_JS_ERROR_CODE_MAP {DMS_ACCOUNT_ACCESS_PERMISSION_DENIED, AbilityErrorCode::ERROR_CODE_PERMISSION_DENIED}, {START_ABILITY_WAITING, AbilityErrorCode::ERROR_START_ABILITY_WAITTING}, {ERR_APP_CONTROLLED, AbilityErrorCode::ERROR_CODE_CONTROLLED}, - {ERR_EDM_APP_CONTROLLED, AbilityErrorCode::ERROR_CODE_EDM_CONTROLLED} + {ERR_EDM_APP_CONTROLLED, AbilityErrorCode::ERROR_CODE_EDM_CONTROLLED}, + {ERR_INSIGHT_INTENT_START_INVALID_COMPONENT, AbilityErrorCode::ERROR_CODE_OPERATION_NOT_SUPPORTED}, }; } diff --git a/frameworks/native/insight_intent/BUILD.gn b/frameworks/native/insight_intent/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..3e54d801aec18c99d8ccf70216d21ad74b5b7e22 --- /dev/null +++ b/frameworks/native/insight_intent/BUILD.gn @@ -0,0 +1,17 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +import("//foundation/ability/ability_runtime/ability_runtime.gni") + +group("insight_intent_innerkits") { + deps = [ "insight_intent_context:insightintentcontext" ] +} diff --git a/frameworks/native/insight_intent/insight_intent_context/BUILD.gn b/frameworks/native/insight_intent/insight_intent_context/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..914cde4cf3afc914fcfe974fb394954bf71a0ba9 --- /dev/null +++ b/frameworks/native/insight_intent/insight_intent_context/BUILD.gn @@ -0,0 +1,39 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/ohos.gni") +import("//foundation/ability/ability_runtime/ability_runtime.gni") + +ohos_shared_library("insightintentcontext") { + include_dirs = [ + "${ability_runtime_innerkits_path}/insight_intent/insight_intent_context", + ] + + sources = [ "insight_intent_context.cpp" ] + + defines = [ "AMS_LOG_TAG = \"InsigtIntent\"" ] + defines += [ "AMS_LOG_DOMAIN = 0xD001308" ] + + deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager" ] + + external_deps = [ + "ability_base:want", + "c_utils:utils", + "hilog:libhilog", + "hitrace:hitrace_meter", + ] + + relative_install_dir = "insight_intent" + subsystem_name = "ability" + part_name = "ability_runtime" +} diff --git a/frameworks/native/insight_intent/insight_intent_context/insight_intent_context.cpp b/frameworks/native/insight_intent/insight_intent_context/insight_intent_context.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b00f441c1aa8a4d645a2f51c31be7bae99bad3da --- /dev/null +++ b/frameworks/native/insight_intent/insight_intent_context/insight_intent_context.cpp @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "insight_intent_context.h" + +#include "ability_manager_client.h" +#include "hilog_wrapper.h" +#include "hitrace_meter.h" + +namespace OHOS { +namespace AbilityRuntime { +ErrCode InsightIntentContext::StartAbilityByInsightIntent(const AAFwk::Want &want) +{ + HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); + HILOG_DEBUG("enter"); + ErrCode err = AAFwk::AbilityManagerClient::GetInstance()->StartAbilityByInsightIntent(want, token_, intentId_); + if (err != ERR_OK) { + HILOG_ERROR("failed to startAbility. ret=%{public}d", err); + } + HILOG_DEBUG("end"); + return err; +} +} // namespace AbilityRuntime +} // namespace OHOS diff --git a/interfaces/inner_api/ability_manager/include/ability_manager_client.h b/interfaces/inner_api/ability_manager/include/ability_manager_client.h index 4da9ef051142e0b256d2073ca94d4c1415aca592..7a6400198f5694047eaa9689ba14b9bb6306bfb8 100644 --- a/interfaces/inner_api/ability_manager/include/ability_manager_client.h +++ b/interfaces/inner_api/ability_manager/include/ability_manager_client.h @@ -134,6 +134,21 @@ public: int requestCode = DEFAULT_INVAL_VALUE, int32_t userId = DEFAULT_INVAL_VALUE); + /** + * StartAbility by insight intent, send want to ability manager service. + * + * @param want Ability want. + * @param callerToken caller ability token. + * @param intentId insight intent id. + * @param userId userId of target ability. + * @return Returns ERR_OK on success, others on failure. + */ + ErrCode StartAbilityByInsightIntent( + const Want &want, + const sptr &callerToken, + uint64_t intentId, + int32_t userId = DEFAULT_INVAL_VALUE); + /** * Starts a new ability with specific start settings. * diff --git a/interfaces/inner_api/ability_manager/include/ability_manager_errors.h b/interfaces/inner_api/ability_manager/include/ability_manager_errors.h index c661f36e7fff764ed31198572513ea9fda2348c3..2b6f078e427410503a081b9a8306ee8be882190b 100644 --- a/interfaces/inner_api/ability_manager/include/ability_manager_errors.h +++ b/interfaces/inner_api/ability_manager/include/ability_manager_errors.h @@ -358,6 +358,10 @@ enum { * Result(2097219) for prouct application boot setting. */ ERR_NOT_SUPPORTED_PRODUCT_TYPE, + /** + * Result(2097220) for starting invalid component. + */ + ERR_INSIGHT_INTENT_START_INVALID_COMPONENT, }; enum { diff --git a/interfaces/inner_api/ability_manager/include/ability_manager_interface.h b/interfaces/inner_api/ability_manager/include/ability_manager_interface.h index 037361334efc312062b8d3d658ea5cf4a76b87f1..f5e040cfe13ba090674cc9f32be065df49582766 100644 --- a/interfaces/inner_api/ability_manager/include/ability_manager_interface.h +++ b/interfaces/inner_api/ability_manager/include/ability_manager_interface.h @@ -100,6 +100,21 @@ public: int32_t userId = DEFAULT_INVAL_VALUE, int requestCode = DEFAULT_INVAL_VALUE) = 0; + /** + * StartAbility by insight intent, send want to ability manager service. + * + * @param want Ability want. + * @param callerToken caller ability token. + * @param intentId insight intent id. + * @param userId userId of target ability. + * @return Returns ERR_OK on success, others on failure. + */ + virtual int32_t StartAbilityByInsightIntent( + const Want &want, + const sptr &callerToken, + uint64_t intentId, + int32_t userId = DEFAULT_INVAL_VALUE) = 0; + /** * Starts a new ability with specific start settings. * diff --git a/interfaces/inner_api/ability_manager/include/ability_manager_ipc_interface_code.h b/interfaces/inner_api/ability_manager/include/ability_manager_ipc_interface_code.h index 4c6605943ce0ccd5b78cd50c9bc14e8b48cb4bc7..5c5819812c5cb961662435b4bfdea7dd355a8807 100644 --- a/interfaces/inner_api/ability_manager/include/ability_manager_ipc_interface_code.h +++ b/interfaces/inner_api/ability_manager/include/ability_manager_ipc_interface_code.h @@ -347,6 +347,9 @@ enum class AbilityManagerInterfaceCode { START_UI_SESSION_ABILITY_FOR_OPTIONS = 1052, + // start ability by insigt intent + START_ABILITY_BY_INSIGHT_INTENT = 1053, + // ipc id for continue ability(1101) START_CONTINUATION = 1101, diff --git a/interfaces/inner_api/insight_intent/insight_intent_context/insight_intent_context.h b/interfaces/inner_api/insight_intent/insight_intent_context/insight_intent_context.h new file mode 100644 index 0000000000000000000000000000000000000000..f5c0c00538300053cdd52bda8ccf9c3679babe19 --- /dev/null +++ b/interfaces/inner_api/insight_intent/insight_intent_context/insight_intent_context.h @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef OHOS_ABILITY_RUNTIME_INSIGHT_INTENT_CONTEXT_H +#define OHOS_ABILITY_RUNTIME_INSIGHT_INTENT_CONTEXT_H + +#include "iremote_object.h" +#include "want.h" + +namespace OHOS { +namespace AbilityRuntime { +/** + * @class InsightIntentContext + * InsightIntentContext provides a context for insightintent to execute certain tasks. + */ +class InsightIntentContext final { +public: + InsightIntentContext(const sptr& token, const std::string& bundleName, int32_t winMode, + uint64_t intentId) : token_(token), bundleName_(bundleName), winMode_(winMode), intentId_(intentId) {} + ~InsightIntentContext() = default; + + /** + * Starts a new ability. Only such ability in the same application with the caller + * can be started. + * + * @param want Indicates the Want containing information about the target ability to start. + * @return result of StartAbility. + */ + ErrCode StartAbilityByInsightIntent(const AAFwk::Want &want); + + std::string GetBundleName() const + { + return bundleName_; + } + + int32_t GetCurrentWindowMode() const + { + return winMode_; + } + +private: + sptr token_ = nullptr; + std::string bundleName_ = ""; + int32_t winMode_ = 0; + uint64_t intentId_ = 0; +}; +} // namespace AbilityRuntime +} // namespace OHOS +#endif // OHOS_ABILITY_RUNTIME_JS_INSIGHT_INTENT_CONTEXT_H diff --git a/interfaces/kits/native/ability/native/ability_business_error/ability_business_error.h b/interfaces/kits/native/ability/native/ability_business_error/ability_business_error.h old mode 100755 new mode 100644 diff --git a/services/abilitymgr/include/ability_manager_proxy.h b/services/abilitymgr/include/ability_manager_proxy.h index 5277a2bff1680a3242dc6f64e3fe2723ea3eeed2..5ffea34d7f092f697c410152b272b861de0c81aa 100644 --- a/services/abilitymgr/include/ability_manager_proxy.h +++ b/services/abilitymgr/include/ability_manager_proxy.h @@ -65,6 +65,21 @@ public: int32_t userId = DEFAULT_INVAL_VALUE, int requestCode = DEFAULT_INVAL_VALUE) override; + /** + * StartAbility by insight intent, send want to ability manager service. + * + * @param want Ability want. + * @param callerToken caller ability token. + * @param intentId insight intent id. + * @param userId userId of target ability. + * @return Returns ERR_OK on success, others on failure. + */ + int32_t StartAbilityByInsightIntent( + const Want &want, + const sptr &callerToken, + uint64_t intentId, + int32_t userId = DEFAULT_INVAL_VALUE) override; + /** * Starts a new ability with specific start settings. * diff --git a/services/abilitymgr/include/ability_manager_service.h b/services/abilitymgr/include/ability_manager_service.h index a4f05442f3d1fa1ae16286fdfdbc3d8ad403e291..b242e60d656ed97e5cc7b3705e2d5623b379f52a 100644 --- a/services/abilitymgr/include/ability_manager_service.h +++ b/services/abilitymgr/include/ability_manager_service.h @@ -120,6 +120,21 @@ public: int32_t userId = DEFAULT_INVAL_VALUE, int requestCode = DEFAULT_INVAL_VALUE) override; + /** + * StartAbility by insight intent, send want to ability manager service. + * + * @param want Ability want. + * @param callerToken caller ability token. + * @param intentId insight intent id. + * @param userId userId of target ability. + * @return Returns ERR_OK on success, others on failure. + */ + int32_t StartAbilityByInsightIntent( + const Want &want, + const sptr &callerToken, + uint64_t intentId, + int32_t userId = DEFAULT_INVAL_VALUE) override; + /** * Starts a new ability with specific start settings. * diff --git a/services/abilitymgr/include/ability_manager_stub.h b/services/abilitymgr/include/ability_manager_stub.h index 30605dd571c001334096edf12093059e05871fda..1795e86c4a74205fe96b942ac3965b9e51165d09 100644 --- a/services/abilitymgr/include/ability_manager_stub.h +++ b/services/abilitymgr/include/ability_manager_stub.h @@ -266,6 +266,9 @@ private: int32_t DetachAppDebugInner(MessageParcel &data, MessageParcel &reply); int32_t IsAbilityControllerStartInner(MessageParcel &data, MessageParcel &reply); + + //insight intent related + int32_t StartAbilityByInsightIntentInner(MessageParcel &data, MessageParcel &reply); }; } // namespace AAFwk } // namespace OHOS diff --git a/services/abilitymgr/src/ability_manager_client.cpp b/services/abilitymgr/src/ability_manager_client.cpp index 7d8e718313bf0ef800ff061ffb0ac190a226614d..90f2ff8c483a877a5c6c5553bd2bfb7541b328ba 100644 --- a/services/abilitymgr/src/ability_manager_client.cpp +++ b/services/abilitymgr/src/ability_manager_client.cpp @@ -153,6 +153,18 @@ ErrCode AbilityManagerClient::StartAbility( return abms->StartAbility(want, callerToken, userId, requestCode); } +ErrCode AbilityManagerClient::StartAbilityByInsightIntent( + const Want &want, const sptr &callerToken, uint64_t intentId, int32_t userId) +{ + HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); + auto abms = GetAbilityManager(); + CHECK_POINTER_RETURN_NOT_CONNECTED(abms); + HILOG_DEBUG("ability:%{public}s, bundle:%{public}s, intentId:%{public}llu", + want.GetElement().GetAbilityName().c_str(), want.GetElement().GetBundleName().c_str(), intentId); + HandleDlpApp(const_cast(want)); + return abms->StartAbilityByInsightIntent(want, callerToken, intentId, userId); +} + ErrCode AbilityManagerClient::StartAbility(const Want &want, const AbilityStartSetting &abilityStartSetting, const sptr &callerToken, int requestCode, int32_t userId) { diff --git a/services/abilitymgr/src/ability_manager_proxy.cpp b/services/abilitymgr/src/ability_manager_proxy.cpp index 71efd5eaf81bfaee3dde4e98cf9d291a159cfa15..7704ea25ee329cb5403af4c84b12a8db16c06100 100644 --- a/services/abilitymgr/src/ability_manager_proxy.cpp +++ b/services/abilitymgr/src/ability_manager_proxy.cpp @@ -216,6 +216,50 @@ int AbilityManagerProxy::StartAbility( return reply.ReadInt32(); } +int32_t AbilityManagerProxy::StartAbilityByInsightIntent(const Want &want, const sptr &callerToken, + uint64_t intentId, int32_t userId) +{ + MessageParcel data; + if (callerToken == nullptr) { + HILOG_ERROR("invalid callertoken."); + return INNER_ERR; + } + + if (!WriteInterfaceToken(data)) { + HILOG_ERROR("want write failed."); + return INNER_ERR; + } + + if (!data.WriteParcelable(&want)) { + HILOG_ERROR("want write failed."); + return INNER_ERR; + } + + if (!data.WriteBool(true) || !data.WriteRemoteObject(callerToken)) { + HILOG_ERROR("callerToken and flag write failed."); + return INNER_ERR; + } + + if (!data.WriteUint64(intentId)) { + HILOG_ERROR("intentId write failed."); + return INNER_ERR; + } + + if (!data.WriteInt32(userId)) { + HILOG_ERROR("userId write failed."); + return INNER_ERR; + } + + MessageParcel reply; + MessageOption option; + int32_t error = SendRequest(AbilityManagerInterfaceCode::START_ABILITY_BY_INSIGHT_INTENT, data, reply, option); + if (error != NO_ERROR) { + HILOG_ERROR("failed to start ability err: %{public}d", error); + return error; + } + return reply.ReadInt32(); +} + int AbilityManagerProxy::StartAbility(const Want &want, const StartOptions &startOptions, const sptr &callerToken, int32_t userId, int requestCode) { diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index 19ab95d9f038cb1f65646eca607f7dd2890f542e..aae17fead33c5f43c95461c0eb75915331b69683 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -474,6 +474,34 @@ int AbilityManagerService::StartAbility(const Want &want, const sptr &callerToken, + uint64_t intentId, int32_t userId) +{ + HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); + // verify bundleName code below will be uncommentted after dependency ready + /*std::string bundleNameFromWant = want.GetElement().GetBundleName(); + std::string bundleNameFromIntentMgr = ""; + if (DelayedSingleton::GetInstance()-> + GetBundleName(intentId, bundleNameFromIntentMgr) != ERR_OK) { + HILOG_ERROR("no such bundle matched intentId"); + return ERR_INVALID_VALUE; + } + auto abilityRecord = Token::GetAbilityRecordByToken(callerToken); + if (abilityRecord == nullptr) { + HILOG_ERROR("no such bundle matched token"); + return ERR_INVALID_VALUE; + } + std::string bundleNameFromAbilityRecord = abilityRecord->GetAbilityInfo().bundleName; + + if (!bundleNameFromWant.empty() && bundleNameFromWant == bundleNameFromIntentMgr && + bundleNameFromWant == bundleNameFromAbilityRecord) { + HILOG_INFO("bundleName match"); + return StartAbility(want, callerToken, userId, -1); + }*/ + HILOG_ERROR("bundleName not match"); + return ERR_INSIGHT_INTENT_START_INVALID_COMPONENT; +} + int AbilityManagerService::StartAbilityByUIContentSession(const Want &want, const sptr &callerToken, const sptr &sessionInfo, int32_t userId, int requestCode) { diff --git a/services/abilitymgr/src/ability_manager_stub.cpp b/services/abilitymgr/src/ability_manager_stub.cpp index 3e6b0160d4025165a7cee8a5b04f0427012fccd3..36f170987239e2079ffe1f92a251e817e3c54171 100644 --- a/services/abilitymgr/src/ability_manager_stub.cpp +++ b/services/abilitymgr/src/ability_manager_stub.cpp @@ -83,6 +83,8 @@ void AbilityManagerStub::FirstStepInit() &AbilityManagerStub::StartAbilityByUIContentSessionAddCallerInner; requestFuncMap_[static_cast(AbilityManagerInterfaceCode::START_UI_SESSION_ABILITY_FOR_OPTIONS)] = &AbilityManagerStub::StartAbilityByUIContentSessionForOptionsInner; + requestFuncMap_[static_cast(AbilityManagerInterfaceCode::START_ABILITY_BY_INSIGHT_INTENT)] = + &AbilityManagerStub::StartAbilityByInsightIntentInner; requestFuncMap_[static_cast(AbilityManagerInterfaceCode::CONNECT_ABILITY)] = &AbilityManagerStub::ConnectAbilityInner; requestFuncMap_[static_cast(AbilityManagerInterfaceCode::DISCONNECT_ABILITY)] = @@ -2791,5 +2793,26 @@ int32_t AbilityManagerStub::IsAbilityControllerStartInner(MessageParcel &data, M reply.WriteBool(result); return NO_ERROR; } + +int32_t AbilityManagerStub::StartAbilityByInsightIntentInner(MessageParcel &data, MessageParcel &reply) +{ + std::unique_ptr want(data.ReadParcelable()); + if (want == nullptr) { + HILOG_ERROR("want is nullptr"); + return ERR_INVALID_VALUE; + } + + sptr callerToken = nullptr; + if (!data.ReadBool()) { + HILOG_ERROR("invalid caller token"); + return ERR_INVALID_VALUE; + } + callerToken = data.ReadRemoteObject(); + uint64_t intentId = data.ReadUint64(); + int32_t userId = data.ReadInt32(); + int32_t result = StartAbilityByInsightIntent(*want, callerToken, intentId, userId); + reply.WriteInt32(result); + return NO_ERROR; +} } // namespace AAFwk } // namespace OHOS diff --git a/test/mock/frameworks_kits_ability_ability_runtime_test/AMS/mock_serviceability_manager_service.h b/test/mock/frameworks_kits_ability_ability_runtime_test/AMS/mock_serviceability_manager_service.h index a6eb571c2d157a282bb738e0d1d111966c04d80c..2779315ca00a8f4891ef831db22430b770be8263 100644 --- a/test/mock/frameworks_kits_ability_ability_runtime_test/AMS/mock_serviceability_manager_service.h +++ b/test/mock/frameworks_kits_ability_ability_runtime_test/AMS/mock_serviceability_manager_service.h @@ -126,6 +126,8 @@ public: MOCK_METHOD2(GetPendingRequestWant, int(const sptr& target, std::shared_ptr& want)); MOCK_METHOD5(StartAbility, int(const Want& want, const AbilityStartSetting& abilityStartSetting, const sptr& callerToken, int32_t userId, int requestCode)); + MOCK_METHOD4(StartAbilityByInsightIntent, int32_t(const Want& want, const sptr& callerToken, + uint64_t intentId, int32_t userId)); MOCK_METHOD1(GetPendinTerminateAbilityTestgRequestWant, void(int id)); MOCK_METHOD3(StartContinuation, int(const Want& want, const sptr& abilityToken, int32_t status)); MOCK_METHOD2(NotifyContinuationResult, int(int32_t missionId, int32_t result)); diff --git a/test/mock/frameworks_kits_ability_native_test/include/mock_ability_manager_service.h b/test/mock/frameworks_kits_ability_native_test/include/mock_ability_manager_service.h index 83fb8bac3db7f49a69c2aae29114b4986e6f0b34..9e4b539ce13130e68bcf70fe24a9ccd7d76d6a8a 100644 --- a/test/mock/frameworks_kits_ability_native_test/include/mock_ability_manager_service.h +++ b/test/mock/frameworks_kits_ability_native_test/include/mock_ability_manager_service.h @@ -105,6 +105,8 @@ public: MOCK_METHOD5(StartAbility, int(const Want& want, const AbilityStartSetting& abilityStartSetting, const sptr& callerToken, int32_t userId, int requestCode)); + MOCK_METHOD4(StartAbilityByInsightIntent, int32_t(const Want& want, const sptr& callerToken, + uint64_t intentId, int32_t userId)); MOCK_METHOD1(GetPendinTerminateAbilityTestgRequestWant, void(int id)); MOCK_METHOD3(StartContinuation, int(const Want& want, const sptr& abilityToken, int32_t status)); MOCK_METHOD2(NotifyContinuationResult, int(int32_t missionId, int32_t result)); diff --git a/test/mock/frameworks_kits_appkit_native_test/ability_delegator/mock_ability_delegator_stub.h b/test/mock/frameworks_kits_appkit_native_test/ability_delegator/mock_ability_delegator_stub.h index e6665eea64a7c0cd926ddb1eb1f386d389310523..a694ae215c244c5a553bc1409aab944c02119bcd 100644 --- a/test/mock/frameworks_kits_appkit_native_test/ability_delegator/mock_ability_delegator_stub.h +++ b/test/mock/frameworks_kits_appkit_native_test/ability_delegator/mock_ability_delegator_stub.h @@ -36,6 +36,8 @@ public: int32_t userId, int requestCode)); MOCK_METHOD5(StartAbility, int(const Want& want, const AbilityStartSetting& abilityStartSetting, const sptr& callerToken, int32_t userId, int requestCode)); + MOCK_METHOD4(StartAbilityByInsightIntent, int32_t(const Want& want, const sptr& callerToken, + uint64_t intentId, int32_t userId)); int StartAbility(const Want& want, const StartOptions& startOptions, const sptr& callerToken, int requestCode = DEFAULT_INVAL_VALUE, int32_t userId = DEFAULT_INVAL_VALUE) override; @@ -195,6 +197,8 @@ public: int32_t userId, int requestCode)); MOCK_METHOD5(StartAbility, int(const Want& want, const AbilityStartSetting& abilityStartSetting, const sptr& callerToken, int32_t userId, int requestCode)); + MOCK_METHOD4(StartAbilityByInsightIntent, int32_t(const Want& want, const sptr& callerToken, + uint64_t intentId, int32_t userId)); int StartAbility(const Want& want, const StartOptions& startOptions, const sptr& callerToken, int requestCode = DEFAULT_INVAL_VALUE, int32_t userId = DEFAULT_INVAL_VALUE) override; diff --git a/test/mock/frameworks_kits_appkit_test/include/mock_ability_mgr_service.h b/test/mock/frameworks_kits_appkit_test/include/mock_ability_mgr_service.h index 1c32ae69ba1b2b4550e051e6539f352e4869dcc5..5f00122a005f93fc351e6583e5fdaf0cb1632eab 100644 --- a/test/mock/frameworks_kits_appkit_test/include/mock_ability_mgr_service.h +++ b/test/mock/frameworks_kits_appkit_test/include/mock_ability_mgr_service.h @@ -29,6 +29,8 @@ public: int requestCode)); MOCK_METHOD5(StartAbility, int(const Want& want, const AbilityStartSetting& abilityStartSetting, const sptr& callerToken, int32_t userId, int requestCode)); + MOCK_METHOD4(StartAbilityByInsightIntent, int32_t(const Want& want, const sptr& callerToken, + uint64_t intentId, int32_t userId)); MOCK_METHOD4(StartAbilityAsCaller, int(const Want& want, const sptr& callerToken, int32_t userId, int requestCode)); MOCK_METHOD5(StartAbilityAsCaller, int(const Want &want, const StartOptions &startOptions, diff --git a/test/mock/frameworks_kits_test/AMS/mock_ability_manager_service.h b/test/mock/frameworks_kits_test/AMS/mock_ability_manager_service.h index d6444c8934831ce01cfe64b8f7bbc8b72ae8f0c4..b523c29e55626d7eee7f57e60e7b05187983b28f 100644 --- a/test/mock/frameworks_kits_test/AMS/mock_ability_manager_service.h +++ b/test/mock/frameworks_kits_test/AMS/mock_ability_manager_service.h @@ -118,6 +118,8 @@ public: MOCK_METHOD2(GetPendingRequestWant, int(const sptr& target, std::shared_ptr& want)); MOCK_METHOD5(StartAbility, int(const Want& want, const AbilityStartSetting& abilityStartSetting, const sptr& callerToken, int32_t userId, int requestCode)); + MOCK_METHOD4(StartAbilityByInsightIntent, int32_t(const Want& want, const sptr& callerToken, + uint64_t intentId, int32_t userId)); MOCK_METHOD1(GetPendinTerminateAbilityTestgRequestWant, void(int id)); MOCK_METHOD3(StartContinuation, int(const Want& want, const sptr& abilityToken, int32_t status)); MOCK_METHOD2(NotifyContinuationResult, int(int32_t missionId, int32_t result)); diff --git a/test/mock/frameworks_kits_test/AMS/mock_serviceability_manager_service.h b/test/mock/frameworks_kits_test/AMS/mock_serviceability_manager_service.h index 512d639ff4789996c8c20c0a1746dd0d3b28953b..eb2759894fe490462456177b36bb83ab08d4495b 100644 --- a/test/mock/frameworks_kits_test/AMS/mock_serviceability_manager_service.h +++ b/test/mock/frameworks_kits_test/AMS/mock_serviceability_manager_service.h @@ -123,6 +123,8 @@ public: MOCK_METHOD2(GetPendingRequestWant, int(const sptr& target, std::shared_ptr& want)); MOCK_METHOD5(StartAbility, int(const Want& want, const AbilityStartSetting& abilityStartSetting, const sptr& callerToken, int32_t userId, int requestCode)); + MOCK_METHOD4(StartAbilityByInsightIntent, int32_t(const Want& want, const sptr& callerToken, + uint64_t intentId, int32_t userId)); MOCK_METHOD1(GetPendinTerminateAbilityTestgRequestWant, void(int id)); MOCK_METHOD3(StartContinuation, int(const Want& want, const sptr& abilityToken, int32_t status)); MOCK_METHOD2(NotifyContinuationResult, int(int32_t missionId, int32_t result)); diff --git a/test/moduletest/mock/include/appmgr/mock_ability_mgr_host.h b/test/moduletest/mock/include/appmgr/mock_ability_mgr_host.h index 6b8ce5a01cf7b00f8bb1346abe2858c658bfaf7a..5671df7ffaeaaedb0b8a119b48a63abd2756a067 100644 --- a/test/moduletest/mock/include/appmgr/mock_ability_mgr_host.h +++ b/test/moduletest/mock/include/appmgr/mock_ability_mgr_host.h @@ -50,6 +50,13 @@ public: { return 0; } + + int32_t StartAbilityByInsightIntent(const Want &want, const sptr &callerToken, + uint64_t intentId, int32_t userId) override + { + return 0; + } + virtual int StartAbilityAsCaller(const Want& want, const sptr& callerToken, int32_t userId = DEFAULT_INVAL_VALUE, int requestCode = -1) override { diff --git a/test/moduletest/mock/include/mock_ability_mgr_service.h b/test/moduletest/mock/include/mock_ability_mgr_service.h index f3218898969d6bf583ea8ba32d8c2c7718d198b7..c420df86b545d3050fdc4a9c35695f426ca8ece5 100644 --- a/test/moduletest/mock/include/mock_ability_mgr_service.h +++ b/test/moduletest/mock/include/mock_ability_mgr_service.h @@ -79,6 +79,8 @@ public: MOCK_METHOD2(GetPendingRequestWant, int(const sptr& target, std::shared_ptr& want)); MOCK_METHOD5(StartAbility, int(const Want& want, const AbilityStartSetting& abilityStartSetting, const sptr& callerToken, int32_t userId, int requestCode)); + MOCK_METHOD4(StartAbilityByInsightIntent, int32_t(const Want& want, const sptr& callerToken, + uint64_t intentId, int32_t userId)); MOCK_METHOD3(StartContinuation, int(const Want& want, const sptr& abilityToken, int32_t status)); MOCK_METHOD2(NotifyContinuationResult, int(int32_t missionId, int32_t result)); MOCK_METHOD5(ContinueMission, int(const std::string& srcDeviceId, const std::string& dstDeviceId, diff --git a/test/unittest/ability_manager_client_branch_test/ability_manager_stub_mock_test.h b/test/unittest/ability_manager_client_branch_test/ability_manager_stub_mock_test.h index 09c0d1b6602808ed0a997c9fe1a3994779ce6dd2..ec03acf464139823070214cf60e6dd481b090e3d 100644 --- a/test/unittest/ability_manager_client_branch_test/ability_manager_stub_mock_test.h +++ b/test/unittest/ability_manager_client_branch_test/ability_manager_stub_mock_test.h @@ -297,6 +297,8 @@ public: MOCK_METHOD4(StartAbility, int(const Want& want, const sptr& callerToken, int32_t userId, int requestCode)); + MOCK_METHOD4(StartAbilityByInsightIntent, int32_t(const Want& want, const sptr& callerToken, + uint64_t intentId, int32_t userId)); MOCK_METHOD4(StartAbilityAsCaller, int(const Want& want, const sptr& callerToken, int32_t userId, int requestCode)); MOCK_METHOD2( diff --git a/test/unittest/ability_manager_proxy_test/ability_manager_stub_mock.h b/test/unittest/ability_manager_proxy_test/ability_manager_stub_mock.h index b220324807732609dadbf4ab1ae34204adc5f972..1468164e5da624e8d5a4558e594783cf3d3b0e72 100644 --- a/test/unittest/ability_manager_proxy_test/ability_manager_stub_mock.h +++ b/test/unittest/ability_manager_proxy_test/ability_manager_stub_mock.h @@ -292,6 +292,8 @@ public: MOCK_METHOD4(StartAbility, int(const Want& want, const sptr& callerToken, int32_t userId, int requestCode)); + MOCK_METHOD4(StartAbilityByInsightIntent, int32_t(const Want& want, const sptr& callerToken, + uint64_t intentId, int32_t userId)); MOCK_METHOD4(StartAbilityAsCaller, int(const Want &want, const sptr &callerToken, int32_t userId, int requestCode)); MOCK_METHOD2( diff --git a/test/unittest/ability_manager_stub_test/ability_manager_stub_impl_mock.h b/test/unittest/ability_manager_stub_test/ability_manager_stub_impl_mock.h index 4d33df6044e2e1f81baa808bcebd95434d58fcd1..0ca7150ec95d09421be1f77f2daaf9cb09917b82 100644 --- a/test/unittest/ability_manager_stub_test/ability_manager_stub_impl_mock.h +++ b/test/unittest/ability_manager_stub_test/ability_manager_stub_impl_mock.h @@ -34,6 +34,8 @@ public: MOCK_METHOD4(StartAbility, int(const Want& want, const sptr& callerToken, int32_t userId, int requestCode)); + MOCK_METHOD4(StartAbilityByInsightIntent, int32_t(const Want& want, const sptr& callerToken, + uint64_t intentId, int32_t userId)); MOCK_METHOD4(StartAbilityAsCaller, int(const Want &want, const sptr &callerToken, int32_t userId, int requestCode)); MOCK_METHOD2( diff --git a/test/unittest/ability_manager_test/ability_manager_stub_mock.h b/test/unittest/ability_manager_test/ability_manager_stub_mock.h index 94717335054002a0de0eafcf941ab45f3a808eac..062670334876f95dc5c8524df08af64675e62be2 100644 --- a/test/unittest/ability_manager_test/ability_manager_stub_mock.h +++ b/test/unittest/ability_manager_test/ability_manager_stub_mock.h @@ -286,6 +286,8 @@ public: MOCK_METHOD4(StartAbility, int(const Want& want, const sptr& callerToken, int32_t userId, int requestCode)); + MOCK_METHOD4(StartAbilityByInsightIntent, int32_t(const Want& want, const sptr& callerToken, + uint64_t intentId, int32_t userId)); MOCK_METHOD4(StartAbilityAsCaller, int(const Want& want, const sptr& callerToken, int32_t userId, int requestCode)); MOCK_METHOD2( diff --git a/test/unittest/service_extension_context_test/ability_manager_stub_mock.h b/test/unittest/service_extension_context_test/ability_manager_stub_mock.h index 3f0b06f98d933d0c66f7c3c0d71f4d14868eab79..b4ca5f2c0ca3c3649308e0e11098a81badb9d486 100644 --- a/test/unittest/service_extension_context_test/ability_manager_stub_mock.h +++ b/test/unittest/service_extension_context_test/ability_manager_stub_mock.h @@ -271,6 +271,8 @@ public: MOCK_METHOD4(StartAbility, int(const Want& want, const sptr& callerToken, int32_t userId, int requestCode)); + MOCK_METHOD4(StartAbilityByInsightIntent, int32_t(const Want& want, const sptr& callerToken, + uint64_t intentId, int32_t userId)); MOCK_METHOD4(StartAbilityAsCaller, int(const Want& want, const sptr& callerToken, int32_t userId, int requestCode)); MOCK_METHOD2( diff --git a/test/unittest/sys_mgr_client_test/mock_ability_manager_service.h b/test/unittest/sys_mgr_client_test/mock_ability_manager_service.h index d8f2004f2b85ea2b65220d73c7cb2257e3fbcfa2..f537df56f47838e7baa09f7cb137e64c01b9857e 100644 --- a/test/unittest/sys_mgr_client_test/mock_ability_manager_service.h +++ b/test/unittest/sys_mgr_client_test/mock_ability_manager_service.h @@ -105,6 +105,8 @@ public: MOCK_METHOD2(GetPendingRequestWant, int(const sptr& target, std::shared_ptr& want)); MOCK_METHOD5(StartAbility, int(const Want& want, const AbilityStartSetting& abilityStartSetting, const sptr& callerToken, int32_t userId, int requestCode)); + MOCK_METHOD4(StartAbilityByInsightIntent, int32_t(const Want& want, const sptr& callerToken, + uint64_t intentId, int32_t userId)); MOCK_METHOD4(StartAbilityAsCaller, int(const Want& want, const sptr& callerToken, int32_t userId, int requestCode)); MOCK_METHOD5(StartAbilityAsCaller, int(const Want &want, const StartOptions &startOptions, diff --git a/tools/test/mock/mock_ability_manager_stub.h b/tools/test/mock/mock_ability_manager_stub.h index 0e0349a6dbbef781649b828abb25d0c2d1320848..b89487c5100e44819c298d4cb8caa2b5d0c3d8b3 100644 --- a/tools/test/mock/mock_ability_manager_stub.h +++ b/tools/test/mock/mock_ability_manager_stub.h @@ -87,6 +87,8 @@ public: MOCK_METHOD2(GetPendingRequestWant, int(const sptr& target, std::shared_ptr& want)); MOCK_METHOD5(StartAbility, int(const Want& want, const AbilityStartSetting& abilityStartSetting, const sptr& callerToken, int32_t userId, int requestCode)); + MOCK_METHOD4(StartAbilityByInsightIntent, int32_t(const Want& want, const sptr& callerToken, + uint64_t intentId, int32_t userId)); MOCK_METHOD1(GetMissionIdByToken, int32_t(const sptr& token)); MOCK_METHOD1(GetPendinTerminateAbilityTestgRequestWant, void(int id)); MOCK_METHOD3(StartContinuation, int(const Want& want, const sptr& abilityToken, int32_t status));