From 4ee0b2559e40db81180ab8556b934a13ac46932d Mon Sep 17 00:00:00 2001 From: zhangyafei-echo Date: Sat, 28 Oct 2023 20:23:00 +0800 Subject: [PATCH] Support uiability foreground mode. Signed-off-by: zhangyafei-echo Change-Id: Id6f90c1fd4369e14f56f0e93bcac14a0a819aefb --- frameworks/native/ability/native/BUILD.gn | 4 +- .../native/ability_runtime/js_ui_ability.cpp | 116 ++++++++++++++++ .../native/ability/native/ui_ability.cpp | 19 +++ .../native/ability/native/ui_ability_impl.cpp | 129 +++++++++++++++++- .../include/ability_manager_client.h | 11 ++ .../include/ability_manager_interface.h | 16 ++- .../ability_manager_ipc_interface_code.h | 3 + .../include/os_account_manager_wrapper.h | 13 +- .../src/os_account_manager_wrapper.cpp | 23 ++++ .../native/ability_runtime/js_ui_ability.h | 46 ++++++- .../kits/native/ability/native/ui_ability.h | 43 +++++- .../native/ability/native/ui_ability_impl.h | 22 +++ .../include/ability_manager_proxy.h | 13 +- .../include/ability_manager_service.h | 13 +- .../abilitymgr/include/ability_manager_stub.h | 1 + .../abilitymgr/src/ability_manager_client.cpp | 13 +- .../abilitymgr/src/ability_manager_proxy.cpp | 34 ++++- .../src/ability_manager_service.cpp | 33 ++++- .../abilitymgr/src/ability_manager_stub.cpp | 23 ++++ .../abilitymgr/src/insight_intent_utils.cpp | 4 +- .../AMS/mock_serviceability_manager_service.h | 2 + .../include/mock_ability_manager_service.h | 2 + .../mock_ability_delegator_stub.h | 4 + .../include/mock_ability_mgr_service.h | 2 + .../AMS/mock_ability_manager_service.h | 4 +- .../AMS/mock_serviceability_manager_service.h | 2 + .../mock/include/mock_ability_mgr_service.h | 2 + .../ability_manager_stub_mock_test.h | 2 + .../ability_manager_stub_mock.h | 2 + .../ability_manager_stub_impl_mock.h | 2 + .../ability_manager_stub_mock.h | 2 + .../ability_manager_stub_mock.h | 2 + .../mock_ability_manager_service.h | 2 + tools/test/mock/mock_ability_manager_stub.h | 2 + 34 files changed, 590 insertions(+), 21 deletions(-) diff --git a/frameworks/native/ability/native/BUILD.gn b/frameworks/native/ability/native/BUILD.gn index 2487d7690a3..4ddab7557cb 100644 --- a/frameworks/native/ability/native/BUILD.gn +++ b/frameworks/native/ability/native/BUILD.gn @@ -247,11 +247,9 @@ ohos_shared_library("abilitykit_native") { "${ability_runtime_innerkits_path}/wantagent:wantagent_innerkits", "${ability_runtime_native_path}/ability:ability_context_native", "${ability_runtime_native_path}/ability/native:ability_business_error", - "${ability_runtime_native_path}/ability/native:insight_intent_executor", "${ability_runtime_native_path}/appkit:app_context", "${ability_runtime_native_path}/appkit:app_context_utils", "${ability_runtime_native_path}/appkit:appkit_delegator", - "${ability_runtime_native_path}/insight_intent/insight_intent_context:insightintentcontext", "${ability_runtime_path}/utils/global/freeze:freeze_util", "${ability_runtime_services_path}/common:event_report", ] @@ -506,8 +504,10 @@ ohos_shared_library("uiabilitykit_native") { "${ability_runtime_innerkits_path}/ability_manager:ability_start_setting", "${ability_runtime_innerkits_path}/runtime:runtime", "${ability_runtime_native_path}/ability:ability_context_native", + "${ability_runtime_native_path}/ability/native:insight_intent_executor", "${ability_runtime_native_path}/appkit:app_context", "${ability_runtime_native_path}/appkit:appkit_delegator", + "${ability_runtime_native_path}/insight_intent/insight_intent_context:insightintentcontext", "${ability_runtime_path}/utils/global/freeze:freeze_util", "${ability_runtime_services_path}/common:event_report", ] 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 b9d15819ac6..37b5f99831b 100644 --- a/frameworks/native/ability/native/ability_runtime/js_ui_ability.cpp +++ b/frameworks/native/ability/native/ability_runtime/js_ui_ability.cpp @@ -18,6 +18,7 @@ #include #include +#include "ability_business_error.h" #include "ability_delegator_registry.h" #include "ability_recovery.h" #include "ability_start_setting.h" @@ -28,6 +29,9 @@ #include "hilog_wrapper.h" #include "hitrace_meter.h" #include "if_system_ability_manager.h" +#include "insight_intent_executor_info.h" +#include "insight_intent_executor_mgr.h" +#include "insight_intent_execute_param.h" #include "js_ability_context.h" #include "js_data_struct_converter.h" #include "js_runtime.h" @@ -475,7 +479,11 @@ void JsUIAbility::OnForeground(const Want &want) } UIAbility::OnForeground(want); + CallOnForegroundFunc(want); +} +void JsUIAbility::CallOnForegroundFunc(const Want &want) +{ HandleScope handleScope(jsRuntime_); auto env = jsRuntime_.GetNapiEnv(); if (jsAbilityObj_ == nullptr) { @@ -653,6 +661,7 @@ void JsUIAbility::DoOnForeground(const Want &want) auto windowMode = want.GetIntParam( Want::PARAM_RESV_WINDOW_MODE, AAFwk::AbilityWindowConfiguration::MULTI_WINDOW_DISPLAY_UNDEFINED); window->SetWindowMode(static_cast(windowMode)); + windowMode_ = windowMode; HILOG_DEBUG("Set window mode is %{public}d.", windowMode); } } @@ -755,6 +764,113 @@ const JsRuntime &JsUIAbility::GetJsRuntime() { return jsRuntime_; } + +void JsUIAbility::ExecuteInsightIntentRepeateForeground(const Want &want, + const std::shared_ptr &executeParam, + std::unique_ptr callback) +{ + HILOG_DEBUG("called."); + if (executeParam == nullptr) { + HILOG_WARN("Intent execute param invalid."); + RequestFocus(want); + InsightIntentExecutorMgr::TriggerCallbackInner(std::move(callback), ERR_OK); + return; + } + + auto asyncCallback = [weak = weak_from_this(), want](InsightIntentExecuteResult result) { + HILOG_DEBUG("Begin request focus."); + auto ability = weak.lock(); + if (ability == nullptr) { + HILOG_ERROR("ability is nullptr."); + return; + } + ability->RequestFocus(want); + }; + callback->Push(asyncCallback); + + InsightIntentExecutorInfo executeInfo; + auto ret = GetInsightIntentExecutorInfo(want, executeParam, executeInfo); + if (!ret) { + HILOG_ERROR("Get Intent executor 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. + HILOG_ERROR("Execute insight intent failed."); + } +} + +void JsUIAbility::ExecuteInsightIntentMoveToForeground(const Want &want, + const std::shared_ptr &executeParam, + std::unique_ptr callback) +{ + HILOG_DEBUG("called."); + if (executeParam == nullptr) { + HILOG_WARN("Intent execute param invalid."); + OnForeground(want); + InsightIntentExecutorMgr::TriggerCallbackInner(std::move(callback), ERR_OK); + return; + } + + if (abilityInfo_) { + jsRuntime_.UpdateModuleNameAndAssetPath(abilityInfo_->moduleName); + } + UIAbility::OnForeground(want); + + auto asyncCallback = [weak = weak_from_this(), want](InsightIntentExecuteResult result) { + HILOG_DEBUG("Begin call onForeground."); + auto ability = weak.lock(); + if (ability == nullptr) { + HILOG_ERROR("ability is nullptr."); + return; + } + ability->CallOnForegroundFunc(want); + }; + callback->Push(asyncCallback); + + InsightIntentExecutorInfo executeInfo; + auto ret = GetInsightIntentExecutorInfo(want, executeParam, executeInfo); + if (!ret) { + HILOG_ERROR("Get Intent executor 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. + HILOG_ERROR("Execute insight intent failed."); + } +} + +bool JsUIAbility::GetInsightIntentExecutorInfo(const Want &want, + const std::shared_ptr &executeParam, + InsightIntentExecutorInfo& executeInfo) +{ + HILOG_DEBUG("called."); + auto context = GetAbilityContext(); + if (executeParam == nullptr || context == nullptr || abilityInfo_ == nullptr || jsWindowStageObj_ == nullptr) { + HILOG_ERROR("Param invalid."); + return false; + } + + const WantParams &wantParams = want.GetParams(); + executeInfo.srcEntry = wantParams.GetStringParam("ohos.insightIntent.srcEntry"); + executeInfo.hapPath = abilityInfo_->hapPath; + executeInfo.esmodule = abilityInfo_->compileMode == AppExecFwk::CompileMode::ES_MODULE; + executeInfo.windowMode = windowMode_; + executeInfo.token = context->GetToken(); + executeInfo.pageLoader = jsWindowStageObj_; + executeInfo.executeParam = executeParam; + return true; +} #endif int32_t JsUIAbility::OnContinue(WantParams &wantParams) diff --git a/frameworks/native/ability/native/ui_ability.cpp b/frameworks/native/ability/native/ui_ability.cpp index 87c532a7dd8..bc06f5f2a80 100644 --- a/frameworks/native/ability/native/ui_ability.cpp +++ b/frameworks/native/ability/native/ui_ability.cpp @@ -973,6 +973,25 @@ void UIAbility::OnChangeForUpdateConfiguration(const AppExecFwk::Configuration & Rosen::Window::UpdateConfigurationForAll(diffConfiguration); } } + +void UIAbility::CallOnForegroundFunc(const AAFwk::Want &want) +{ + HILOG_DEBUG("called"); +} + +void UIAbility::ExecuteInsightIntentRepeateForeground(const AAFwk::Want &want, + const std::shared_ptr &executeParam, + std::unique_ptr callback) +{ + HILOG_DEBUG("called"); +} + +void UIAbility::ExecuteInsightIntentMoveToForeground(const AAFwk::Want &want, + const std::shared_ptr &executeParam, + std::unique_ptr callback) +{ + HILOG_DEBUG("called"); +} #endif } // namespace AbilityRuntime } // namespace OHOS diff --git a/frameworks/native/ability/native/ui_ability_impl.cpp b/frameworks/native/ability/native/ui_ability_impl.cpp index a278bda7aa4..89d9135454a 100644 --- a/frameworks/native/ability/native/ui_ability_impl.cpp +++ b/frameworks/native/ability/native/ui_ability_impl.cpp @@ -217,6 +217,15 @@ void UIAbilityImpl::AbilityTransactionCallback(const AAFwk::AbilityLifeCycleStat } } +void UIAbilityImpl::ExecuteInsightIntentDone(uint64_t intentId, const InsightIntentExecuteResult &result) +{ + HILOG_INFO("Notify execute done, intentId %{public}" PRIu64"", intentId); + auto ret = AAFwk::AbilityManagerClient::GetInstance()->ExecuteInsightIntentDone(token_, intentId, result); + if (ret != ERR_OK) { + HILOG_ERROR("Notify execute done faild."); + } +} + bool UIAbilityImpl::PrepareTerminateAbility() { HILOG_DEBUG("Begin."); @@ -562,7 +571,11 @@ bool UIAbilityImpl::AbilityTransaction(const AAFwk::Want &want, const AAFwk::Lif NewWant(want); } #ifdef SUPPORT_GRAPHICS - HandleForegroundNewState(want, ret); + if (!InsightIntentExecuteParam::IsInsightIntentExecute(want)) { + HandleForegroundNewState(want, ret); + } else { + HandleExecuteInsightIntentForeground(want, ret); + } #endif break; } @@ -606,6 +619,120 @@ void UIAbilityImpl::HandleForegroundNewState(const AAFwk::Want &want, bool &bfla } } } + +void UIAbilityImpl::HandleExecuteInsightIntentForeground(const AAFwk::Want &want, bool &bflag) +{ + HILOG_INFO("Execute insight intent in foreground mode."); + auto executeParam = std::make_shared(); + auto ret = InsightIntentExecuteParam::GenerateFromWant(want, *executeParam); + if (!ret) { + HILOG_ERROR("Generate execute param failed."); + HandleForegroundNewState(want, bflag); + return; + } + + HILOG_DEBUG("Insight intent bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s" + "insightIntentName: %{public}s, executeMode: %{public}d, intentId: %{public}" PRIu64"", + executeParam->bundleName_.c_str(), executeParam->moduleName_.c_str(), executeParam->abilityName_.c_str(), + executeParam->insightIntentName_.c_str(), executeParam->executeMode_, executeParam->insightIntentId_); + auto intentCb = std::make_unique(); + intentCb.reset(InsightIntentExecutorAsyncCallback::Create()); + if (intentCb == nullptr) { + HILOG_ERROR("Create async callback failed."); + HandleForegroundNewState(want, bflag); + return; + } + + if (lifecycleState_ == AAFwk::ABILITY_STATE_FOREGROUND_NEW) { + ExecuteInsightIntentRepeateForeground(want, executeParam, std::move(intentCb)); + } else { + ExecuteInsightIntentMoveToForeground(want, executeParam, std::move(intentCb)); + } + + bflag = false; +} + +void UIAbilityImpl::ExecuteInsightIntentRepeateForeground(const Want &want, + const std::shared_ptr &executeParam, + std::unique_ptr callback) +{ + HILOG_DEBUG("called."); + auto asyncCallback = + [weak = weak_from_this(), intentId = executeParam->insightIntentId_](InsightIntentExecuteResult result) { + HILOG_DEBUG("Execute insight intent finshed, intentId %{public}" PRIu64"", intentId); + auto abilityImpl = weak.lock(); + if (abilityImpl == nullptr) { + HILOG_ERROR("Ability impl is nullptr."); + return; + } + abilityImpl->ExecuteInsightIntentDone(intentId, result); + abilityImpl->AbilityTransactionCallback(AAFwk::ABILITY_STATE_FOREGROUND_NEW); + }; + callback->Push(asyncCallback); + + // private function, no need check ability_ validity. + ability_->ExecuteInsightIntentRepeateForeground(want, executeParam, std::move(callback)); +} + +void UIAbilityImpl::ExecuteInsightIntentMoveToForeground(const Want &want, + const std::shared_ptr &executeParam, + std::unique_ptr callback) +{ + HILOG_DEBUG("called."); + + { + std::lock_guard lock(notifyForegroundLock_); + notifyForegroundByWindow_ = false; + } + + auto asyncCallback = + [weak = weak_from_this(), intentId = executeParam->insightIntentId_](InsightIntentExecuteResult result) { + HILOG_DEBUG("Execute insight intent finshed, intentId %{public}" PRIu64"", intentId); + auto abilityImpl = weak.lock(); + if (abilityImpl == nullptr) { + HILOG_ERROR("Ability impl is nullptr."); + return; + } + abilityImpl->ExecuteInsightIntentDone(intentId, result); + abilityImpl->PostForegroundInsightIntent(); + }; + callback->Push(asyncCallback); + + // private function, no need check ability_ validity. + ability_->ExecuteInsightIntentMoveToForeground(want, executeParam, std::move(callback)); +} + +void UIAbilityImpl::PostForegroundInsightIntent() +{ + HILOG_DEBUG("called"); + if (ability_ == nullptr || abilityLifecycleCallbacks_ == nullptr) { + HILOG_ERROR("Ability params invalid."); + return; + } + + lifecycleState_ = AAFwk::ABILITY_STATE_FOREGROUND_NEW; + + { + std::lock_guard lock(notifyForegroundLock_); + notifyForegroundByAbility_ = true; + } + + abilityLifecycleCallbacks_->OnAbilityForeground(ability_); + + bool flag = true; + { + std::lock_guard lock(notifyForegroundLock_); + flag = notifyForegroundByWindow_; + if (flag) { + notifyForegroundByWindow_ = false; + notifyForegroundByAbility_ = false; + } + } + + if (flag) { + AbilityTransactionCallback(AAFwk::ABILITY_STATE_FOREGROUND_NEW); + } +} #endif } // 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 49d1aedc63a..56e6b109854 100644 --- a/interfaces/inner_api/ability_manager/include/ability_manager_client.h +++ b/interfaces/inner_api/ability_manager/include/ability_manager_client.h @@ -1320,6 +1320,17 @@ public: ErrCode ExecuteIntent(uint64_t key, const sptr &callerToken, const InsightIntentExecuteParam ¶m); + /** + * @brief Called when insight intent execute finished. + * + * @param token ability's token. + * @param intentId insight intent id. + * @param result insight intent execute result. + * @return Returns ERR_OK on success, others on failure. + */ + ErrCode ExecuteInsightIntentDone(const sptr &token, uint64_t intentId, + const InsightIntentExecuteResult &result); + private: class AbilityMgrDeathRecipient : public IRemoteObject::DeathRecipient { public: 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 0103d2a6b36..f7156fd5daf 100644 --- a/interfaces/inner_api/ability_manager/include/ability_manager_interface.h +++ b/interfaces/inner_api/ability_manager/include/ability_manager_interface.h @@ -62,6 +62,7 @@ namespace OHOS { namespace AAFwk { using AutoStartupInfo = AbilityRuntime::AutoStartupInfo; using InsightIntentExecuteParam = AppExecFwk::InsightIntentExecuteParam; +using InsightIntentExecuteResult = AppExecFwk::InsightIntentExecuteResult; constexpr const char* ABILITY_MANAGER_SERVICE_NAME = "AbilityManagerService"; const int DEFAULT_INVAL_VALUE = -1; const int DELAY_LOCAL_FREE_INSTALL_TIMEOUT = 40000; @@ -508,10 +509,10 @@ public: virtual int AttachAbilityThread(const sptr &scheduler, const sptr &token) = 0; /** - * AbilityTransitionDone, ability call this interface after lift cycle was changed. + * AbilityTransitionDone, ability call this interface after life cycle was changed. * * @param token,.ability's token. - * @param state,.the state of ability lift cycle. + * @param state,.the state of ability life cycle. * @return Returns ERR_OK on success, others on failure. */ virtual int AbilityTransitionDone(const sptr &token, int state, const PacMap &saveData) = 0; @@ -1318,6 +1319,17 @@ public: { return true; } + + /** + * @brief Called when insight intent execute finished. + * + * @param token ability's token. + * @param intentId insight intent id. + * @param result insight intent execute result. + * @return Returns ERR_OK on success, others on failure. + */ + virtual int32_t ExecuteInsightIntentDone(const sptr &token, uint64_t intentId, + const InsightIntentExecuteResult &result) = 0; }; } // namespace AAFwk } // namespace OHOS 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 85ea6a88c46..084e79bc96e 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 @@ -227,6 +227,9 @@ enum class AbilityManagerInterfaceCode { // Execute intent (72) EXECUTE_INTENT = 72, + // execute insight intent done with result (73) + EXECUTE_INSIGHT_INTENT_DONE = 73, + // ipc id 1001-2000 for DMS // ipc id for starting ability (1001) START_ABILITY = 1001, diff --git a/interfaces/inner_api/deps_wrapper/include/os_account_manager_wrapper.h b/interfaces/inner_api/deps_wrapper/include/os_account_manager_wrapper.h index 675ab294247..826ca5b843a 100644 --- a/interfaces/inner_api/deps_wrapper/include/os_account_manager_wrapper.h +++ b/interfaces/inner_api/deps_wrapper/include/os_account_manager_wrapper.h @@ -78,7 +78,14 @@ public: * @return error code, ERR_OK on success, others on failure. */ ErrCode RemoveOsAccount(const int id); + + /** + * @brief Get the current active user ID. + * + * @return int32_t user ID + */ + static int32_t GetCurrentActiveAccountId(); }; -} // namespace AppExecFwk -} // namespace OHOS -#endif // OHOS_ABILITY_RUNTIME_OS_ACCOUNT_MANAGER_WRAPPER_H \ No newline at end of file +} // namespace AppExecFwk +} // namespace OHOS +#endif // OHOS_ABILITY_RUNTIME_OS_ACCOUNT_MANAGER_WRAPPER_H \ No newline at end of file diff --git a/interfaces/inner_api/deps_wrapper/src/os_account_manager_wrapper.cpp b/interfaces/inner_api/deps_wrapper/src/os_account_manager_wrapper.cpp index 92dd371697c..dcb979b42a3 100644 --- a/interfaces/inner_api/deps_wrapper/src/os_account_manager_wrapper.cpp +++ b/interfaces/inner_api/deps_wrapper/src/os_account_manager_wrapper.cpp @@ -104,5 +104,28 @@ ErrCode OsAccountManagerWrapper::RemoveOsAccount(const int id) return AccountSA::OsAccountManager::RemoveOsAccount(id); #endif // OS_ACCOUNT_PART_ENABLED } + +int32_t OsAccountManagerWrapper::GetCurrentActiveAccountId() +{ + std::vector accountIds; + auto instance = DelayedSingleton::GetInstance(); + if (instance == nullptr) { + HILOG_ERROR("Failed to get OsAccountManager instance."); + return 0; + } + + ErrCode ret = instance->QueryActiveOsAccountIds(accountIds); + if (ret != ERR_OK) { + HILOG_ERROR("Query active account id failed."); + return 0; + } + + if (accountIds.empty()) { + HILOG_ERROR("No active account."); + return 0; + } + + return accountIds[0]; +} } // namespace AppExecFwk } // namespace OHOS \ No newline at end of file diff --git a/interfaces/kits/native/ability/native/ability_runtime/js_ui_ability.h b/interfaces/kits/native/ability/native/ability_runtime/js_ui_ability.h index 9536938bdcc..ff540813207 100644 --- a/interfaces/kits/native/ability/native/ability_runtime/js_ui_ability.h +++ b/interfaces/kits/native/ability/native/ability_runtime/js_ui_ability.h @@ -25,12 +25,16 @@ class NativeReference; namespace OHOS { namespace AbilityRuntime { class JsRuntime; +struct InsightIntentExecutorInfo; using AbilityHandler = AppExecFwk::AbilityHandler; using AbilityInfo = AppExecFwk::AbilityInfo; using OHOSApplication = AppExecFwk::OHOSApplication; using Want = AppExecFwk::Want; using AbilityStartSetting = AppExecFwk::AbilityStartSetting; using Configuration = AppExecFwk::Configuration; +using InsightIntentExecuteResult = AppExecFwk::InsightIntentExecuteResult; +using InsightIntentExecuteParam = AppExecFwk::InsightIntentExecuteParam; +using InsightIntentExecutorAsyncCallback = AppExecFwk::InsightIntentExecutorAsyncCallback; class JsUIAbility : public UIAbility { public: @@ -189,6 +193,20 @@ public: */ void OnForeground(const Want &want) override; + /** + * @brief Call "onForeground" js function barely. + * + * @param want Want + */ + void CallOnForegroundFunc(const Want &want) override; + + /** + * @brief Request focus for current window, can be override. + * + * @param want Want + */ + void RequestFocus(const Want &want) override; + /** * @brief Called when this ability enters the STATE_BACKGROUND state. * The ability in the STATE_BACKGROUND state is invisible. @@ -220,9 +238,30 @@ public: */ const JsRuntime &GetJsRuntime(); + /** + * @brief Execute insight intent when an ability is in foreground, schedule it to foreground repeatly. + * + * @param want Want. + * @param executeParam insight intent execute param. + * @param callback insight intent async callback. + */ + void ExecuteInsightIntentRepeateForeground(const Want &want, + const std::shared_ptr &executeParam, + std::unique_ptr callback) override; + + /** + * @brief Execute insight intent when an ability didn't started or in background, schedule it to foreground. + * + * @param want Want. + * @param executeParam insight intent execute param. + * @param callback insight intent async callback. + */ + void ExecuteInsightIntentMoveToForeground(const Want &want, + const std::shared_ptr &executeParam, + std::unique_ptr callback) override; + protected: void DoOnForeground(const Want &want) override; - void RequestFocus(const Want &want) override; void ContinuationRestore(const Want &want) override; private: @@ -230,7 +269,12 @@ private: void RestorePageStack(const Want &want); void GetPageStackFromWant(const Want &want, std::string &pageStack); void AbilityContinuationOrRecover(const Want &want); + inline bool GetInsightIntentExecutorInfo(const Want &want, + const std::shared_ptr &executeParam, + InsightIntentExecutorInfo& executeInfo); + std::shared_ptr jsWindowStageObj_; + int32_t windowMode_ = 0; #endif private: diff --git a/interfaces/kits/native/ability/native/ui_ability.h b/interfaces/kits/native/ability/native/ui_ability.h index e3bad2e307c..016294aca4b 100644 --- a/interfaces/kits/native/ability/native/ui_ability.h +++ b/interfaces/kits/native/ability/native/ui_ability.h @@ -41,9 +41,15 @@ class OHOSApplication; class LifeCycle; class ContinuationHandlerStage; class ContinuationManagerStage; +class InsightIntentExecuteParam; +struct InsightIntentExecuteResult; +using InsightIntentExecutorAsyncCallback = AbilityTransactionCallbackInfo; } // namespace AppExecFwk namespace AbilityRuntime { class Runtime; +using InsightIntentExecuteResult = AppExecFwk::InsightIntentExecuteResult; +using InsightIntentExecuteParam = AppExecFwk::InsightIntentExecuteParam; +using InsightIntentExecutorAsyncCallback = AppExecFwk::InsightIntentExecutorAsyncCallback; class UIAbility : public AppExecFwk::AbilityContext, public AppExecFwk::ILifeCycle, public AppExecFwk::IAbilityCallback, @@ -441,6 +447,42 @@ public: */ Ace::UIContent *GetUIContent() override; + /** + * @brief Call "onForeground" js function barely. + * + * @param want Want + */ + virtual void CallOnForegroundFunc(const AAFwk::Want &want); + + /** + * @brief Request focus for current window, can be override. + * + * @param want Want + */ + virtual void RequestFocus(const AAFwk::Want &want); + + /** + * @brief Execute insight intent when an ability is in foreground, schedule it to foreground repeatly. + * + * @param want Want. + * @param executeParam insight intent execute param. + * @param callback insight intent async callback. + */ + virtual void ExecuteInsightIntentRepeateForeground(const AAFwk::Want &want, + const std::shared_ptr &executeParam, + std::unique_ptr callback); + + /** + * @brief Execute insight intent when an ability didn't started or in background, schedule it to foreground. + * + * @param want Want. + * @param executeParam insight intent execute param. + * @param callback insight intent async callback. + */ + virtual void ExecuteInsightIntentMoveToForeground(const AAFwk::Want &want, + const std::shared_ptr &executeParam, + std::unique_ptr callback); + protected: class UIAbilityDisplayListener : public OHOS::Rosen::DisplayManager::IDisplayListener { public: @@ -499,7 +541,6 @@ protected: void OnDisplayMove(Rosen::DisplayId from, Rosen::DisplayId to); virtual void DoOnForeground(const AAFwk::Want &want); - virtual void RequestFocus(const AAFwk::Want &want); sptr GetWindowOption(const AAFwk::Want &want); virtual void ContinuationRestore(const AAFwk::Want &want); diff --git a/interfaces/kits/native/ability/native/ui_ability_impl.h b/interfaces/kits/native/ability/native/ui_ability_impl.h index d16abfffa96..00f21298c92 100644 --- a/interfaces/kits/native/ability/native/ui_ability_impl.h +++ b/interfaces/kits/native/ability/native/ui_ability_impl.h @@ -16,6 +16,7 @@ #ifndef OHOS_ABILITY_RUNTIME_UI_ABILITY_IMPL_H #define OHOS_ABILITY_RUNTIME_UI_ABILITY_IMPL_H +#include "insight_intent_execute_result.h" #include "ui_ability.h" namespace OHOS { @@ -78,6 +79,14 @@ public: */ void AbilityTransactionCallback(const AAFwk::AbilityLifeCycleState &state); + /** + * @brief Execute insight intent done, similar to AbilityTransactionCallback. + * + * @param intentId insight intent id. + * @param result insight intent execute result. + */ + void ExecuteInsightIntentDone(uint64_t intentId, const AppExecFwk::InsightIntentExecuteResult &result); + /** * @brief Handling the life cycle switching of NewAbility in switch. * @param want Indicates the structure containing information about the ability. @@ -159,6 +168,12 @@ public: */ void AfterFocused(); + /** + * @brief Post action when insight intent has executed. + * + */ + void PostForegroundInsightIntent(); + protected: /** * @brief Toggles the lifecycle status of Ability to AAFwk::ABILITY_STATE_INACTIVE. And notifies the application @@ -204,6 +219,13 @@ private: #ifdef SUPPORT_GRAPHICS private: void HandleForegroundNewState(const AAFwk::Want &want, bool &bFlag); + void HandleExecuteInsightIntentForeground(const AAFwk::Want &want, bool &bflag); + inline void ExecuteInsightIntentRepeateForeground(const Want &want, + const std::shared_ptr &executeParam, + std::unique_ptr callback); + inline void ExecuteInsightIntentMoveToForeground(const Want &want, + const std::shared_ptr &executeParam, + std::unique_ptr callback); class WindowLifeCycleImpl : public Rosen::IWindowLifeCycle { public: diff --git a/services/abilitymgr/include/ability_manager_proxy.h b/services/abilitymgr/include/ability_manager_proxy.h index 3e8a72e5ec9..389dcb32ada 100644 --- a/services/abilitymgr/include/ability_manager_proxy.h +++ b/services/abilitymgr/include/ability_manager_proxy.h @@ -1013,7 +1013,7 @@ public: * @return Returns ERR_OK on success, others on failure. */ int32_t RegisterAppDebugListener(const sptr &listener) override; - + /** * @brief Unregister app debug listener. * @param listener App debug listener. @@ -1052,6 +1052,17 @@ public: */ virtual bool IsAbilityControllerStart(const Want &want) override; + /** + * @brief Called when insight intent execute finished. + * + * @param token ability's token. + * @param intentId insight intent id. + * @param result insight intent execute result. + * @return Returns ERR_OK on success, others on failure. + */ + int32_t ExecuteInsightIntentDone(const sptr &token, uint64_t intentId, + const InsightIntentExecuteResult &result) override; + private: template int GetParcelableInfos(MessageParcel &reply, std::vector &parcelableInfos); diff --git a/services/abilitymgr/include/ability_manager_service.h b/services/abilitymgr/include/ability_manager_service.h index 0f7669a42a9..2c834d66339 100644 --- a/services/abilitymgr/include/ability_manager_service.h +++ b/services/abilitymgr/include/ability_manager_service.h @@ -1322,7 +1322,7 @@ public: * @return Returns ERR_OK on success, others on failure. */ int32_t RegisterAppDebugListener(const sptr &listener) override; - + /** * @brief Unregister app debug listener. * @param listener App debug listener. @@ -1364,6 +1364,17 @@ public: */ virtual bool IsAbilityControllerStart(const Want &want) override; + /** + * @brief Called when insight intent execute finished. + * + * @param token ability's token. + * @param intentId insight intent id. + * @param result insight intent execute result. + * @return Returns ERR_OK on success, others on failure. + */ + int32_t ExecuteInsightIntentDone(const sptr &token, uint64_t intentId, + const InsightIntentExecuteResult &result) override; + // MSG 0 - 20 represents timeout message static constexpr uint32_t LOAD_TIMEOUT_MSG = 0; static constexpr uint32_t ACTIVE_TIMEOUT_MSG = 1; diff --git a/services/abilitymgr/include/ability_manager_stub.h b/services/abilitymgr/include/ability_manager_stub.h index 644d50cf96b..2279bbd9880 100644 --- a/services/abilitymgr/include/ability_manager_stub.h +++ b/services/abilitymgr/include/ability_manager_stub.h @@ -270,6 +270,7 @@ private: //insight intent related int32_t StartAbilityByInsightIntentInner(MessageParcel &data, MessageParcel &reply); + int32_t ExecuteInsightIntentDoneInner(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 22059979b3e..575f4bbd5f2 100644 --- a/services/abilitymgr/src/ability_manager_client.cpp +++ b/services/abilitymgr/src/ability_manager_client.cpp @@ -1627,5 +1627,14 @@ bool AbilityManagerClient::IsAbilityControllerStart(const Want &want) } return abms->IsAbilityControllerStart(want); } -} // namespace AAFwk -} // namespace OHOS + +ErrCode AbilityManagerClient::ExecuteInsightIntentDone(const sptr &token, uint64_t intentId, + const InsightIntentExecuteResult &result) +{ + HILOG_DEBUG("Called."); + auto abms = GetAbilityManager(); + CHECK_POINTER_RETURN_NOT_CONNECTED(abms); + return abms->ExecuteInsightIntentDone(token, intentId, result); +} +} // namespace AAFwk +} // namespace OHOS diff --git a/services/abilitymgr/src/ability_manager_proxy.cpp b/services/abilitymgr/src/ability_manager_proxy.cpp index 36970217fc1..696a2037733 100644 --- a/services/abilitymgr/src/ability_manager_proxy.cpp +++ b/services/abilitymgr/src/ability_manager_proxy.cpp @@ -2182,7 +2182,7 @@ void AbilityManagerProxy::SetLockedState(int32_t sessionId, bool lockedState) HILOG_ERROR("WriteBool fail."); return; } - + MessageParcel reply; MessageOption option(MessageOption::TF_ASYNC); auto error = SendRequest(AbilityManagerInterfaceCode::SET_SESSION_LOCKED_STATE, data, reply, option); @@ -4539,7 +4539,7 @@ bool AbilityManagerProxy::IsAbilityControllerStart(const Want &want) HILOG_ERROR("WriteWantObject failed."); return true; } - + auto error = SendRequest(AbilityManagerInterfaceCode::IS_ABILITY_CONTROLLER_START, data, reply, option); if (error != NO_ERROR) { @@ -4549,6 +4549,36 @@ bool AbilityManagerProxy::IsAbilityControllerStart(const Want &want) return reply.ReadBool(); } +int32_t AbilityManagerProxy::ExecuteInsightIntentDone(const sptr &token, uint64_t intentId, + const InsightIntentExecuteResult &result) +{ + HILOG_DEBUG("Called."); + MessageParcel data; + if (!WriteInterfaceToken(data)) { + HILOG_ERROR("Write remote object failed."); + return INNER_ERR; + } + + if (!data.WriteRemoteObject(token)) { + HILOG_ERROR("Write token failed."); + return INNER_ERR; + } + + if (!data.WriteInt64(intentId) || !data.WriteParcelable(&result)) { + HILOG_ERROR("Write insight intent params failed."); + return INNER_ERR; + } + + MessageParcel reply; + MessageOption option; + auto ret = SendRequest(AbilityManagerInterfaceCode::EXECUTE_INSIGHT_INTENT_DONE, data, reply, option); + if (ret != NO_ERROR) { + HILOG_ERROR("Send request failed with %{public}d", ret); + return ret; + } + return reply.ReadInt32(); +} + ErrCode AbilityManagerProxy::SendRequest(AbilityManagerInterfaceCode code, MessageParcel &data, MessageParcel &reply, MessageOption& option) { diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index be383cb6b8c..5d71a28f999 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -482,8 +482,7 @@ int32_t AbilityManagerService::StartAbilityByInsightIntent(const Want &want, con 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 bundleNameFromWant = want.GetElement().GetBundleName(); std::string bundleNameFromIntentMgr = ""; if (DelayedSingleton::GetInstance()-> GetBundleName(intentId, bundleNameFromIntentMgr) != ERR_OK) { @@ -501,7 +500,7 @@ int32_t AbilityManagerService::StartAbilityByInsightIntent(const Want &want, con bundleNameFromWant == bundleNameFromAbilityRecord) { HILOG_INFO("bundleName match"); return StartAbility(want, callerToken, userId, -1); - }*/ + } HILOG_ERROR("bundleName not match"); return ERR_INSIGHT_INTENT_START_INVALID_COMPONENT; } @@ -8745,5 +8744,33 @@ bool AbilityManagerService::IsAbilityControllerStart(const Want &want) HILOG_ERROR("The interface only support for broker"); return true; } + +int32_t AbilityManagerService::ExecuteInsightIntentDone(const sptr &token, uint64_t intentId, + const InsightIntentExecuteResult &result) +{ + HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); + auto abilityRecord = Token::GetAbilityRecordByToken(token); + CHECK_POINTER_AND_RETURN_LOG(abilityRecord, ERR_INVALID_VALUE, "Ability record is nullptr."); + if (!JudgeSelfCalled(abilityRecord)) { + return CHECK_PERMISSION_FAILED; + } + + // check send by same bundleName. + std::string bundleNameStored = ""; + auto ret = DelayedSingleton::GetInstance()->GetBundleName(intentId, bundleNameStored); + if (ret != ERR_OK) { + HILOG_ERROR("Get matched bundleName failed, intentId: %{public}" PRIu64"", intentId); + return ERR_INVALID_VALUE; + } + + std::string bundleName = abilityRecord->GetAbilityInfo().bundleName; + if (bundleNameStored != bundleName) { + HILOG_ERROR("BundleName %{public}s and %{public}s mismatch.", bundleName.c_str(), bundleNameStored.c_str()); + return ERR_INVALID_VALUE; + } + + return DelayedSingleton::GetInstance()->ExecuteIntentDone( + intentId, result.innerErr, result); +} } // namespace AAFwk } // namespace OHOS diff --git a/services/abilitymgr/src/ability_manager_stub.cpp b/services/abilitymgr/src/ability_manager_stub.cpp index 039e6a22f56..66efb7d2b39 100644 --- a/services/abilitymgr/src/ability_manager_stub.cpp +++ b/services/abilitymgr/src/ability_manager_stub.cpp @@ -163,6 +163,8 @@ void AbilityManagerStub::FirstStepInit() &AbilityManagerStub::IsAbilityControllerStartInner; requestFuncMap_[static_cast(AbilityManagerInterfaceCode::EXECUTE_INTENT)] = &AbilityManagerStub::ExecuteIntentInner; + requestFuncMap_[static_cast(AbilityManagerInterfaceCode::EXECUTE_INSIGHT_INTENT_DONE)] = + &AbilityManagerStub::ExecuteInsightIntentDoneInner; } void AbilityManagerStub::SecondStepInit() @@ -2837,5 +2839,26 @@ int32_t AbilityManagerStub::StartAbilityByInsightIntentInner(MessageParcel &data reply.WriteInt32(result); return NO_ERROR; } + +int32_t AbilityManagerStub::ExecuteInsightIntentDoneInner(MessageParcel &data, MessageParcel &reply) +{ + HILOG_DEBUG("Called."); + auto token = data.ReadRemoteObject(); + if (token == nullptr) { + HILOG_ERROR("Failed to get remote object."); + return ERR_INVALID_VALUE; + } + + auto intentId = data.ReadInt64(); + std::unique_ptr executeResult(data.ReadParcelable()); + if (!executeResult) { + HILOG_ERROR("Execute result is nullptr"); + return ERR_INVALID_VALUE; + } + + int32_t result = ExecuteInsightIntentDone(token, intentId, *executeResult); + reply.WriteInt32(result); + return NO_ERROR; +} } // namespace AAFwk } // namespace OHOS diff --git a/services/abilitymgr/src/insight_intent_utils.cpp b/services/abilitymgr/src/insight_intent_utils.cpp index 003c198e1b3..306d9659d42 100644 --- a/services/abilitymgr/src/insight_intent_utils.cpp +++ b/services/abilitymgr/src/insight_intent_utils.cpp @@ -21,6 +21,7 @@ #include "insight_intent_profile.h" #include "iservice_registry.h" #include "module_info.h" +#include "os_account_manager_wrapper.h" #include "system_ability_definition.h" namespace OHOS { @@ -65,7 +66,8 @@ std::string InsightIntentUtils::GetSrcEntry(const std::string &bundleName, const // Get json profile firstly std::string profile; - auto ret = IN_PROCESS_CALL(bundleMgr->GetJsonProfile(AppExecFwk::INTENT_PROFILE, bundleName, moduleName, profile)); + auto ret = IN_PROCESS_CALL(bundleMgr->GetJsonProfile(AppExecFwk::INTENT_PROFILE, bundleName, moduleName, profile, + AppExecFwk::OsAccountManagerWrapper::GetCurrentActiveAccountId())); if (ret != ERR_OK) { HILOG_ERROR("Get json profile failed, error code: %{public}d.", ret); return std::string(""); 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 752fc8ce764..034924c8d58 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 @@ -323,6 +323,8 @@ public: MOCK_METHOD1(DetachAppDebug, int32_t(const std::string &bundleName)); MOCK_METHOD3(ExecuteIntent, int32_t(uint64_t key, const sptr &callerToken, const InsightIntentExecuteParam ¶m)); + MOCK_METHOD3(ExecuteInsightIntentDone, int32_t(const sptr &token, uint64_t intentId, + const InsightIntentExecuteResult &result)); sptr abilityScheduler_ = nullptr; // kit interface used to schedule ability life Want want_; 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 1b3ce0cb41b..c5bf240b99e 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 @@ -291,6 +291,8 @@ public: MOCK_METHOD1(DetachAppDebug, int32_t(const std::string &bundleName)); MOCK_METHOD3(ExecuteIntent, int32_t(uint64_t key, const sptr &callerToken, const InsightIntentExecuteParam ¶m)); + MOCK_METHOD3(ExecuteInsightIntentDone, int32_t(const sptr &token, uint64_t intentId, + const InsightIntentExecuteResult &result)); enum class RequestCode { E_STATE_INITIAL = 0, 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 31afaa4f2ae..cae180de548 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 @@ -178,6 +178,8 @@ public: MOCK_METHOD1(DetachAppDebug, int32_t(const std::string &bundleName)); MOCK_METHOD3(ExecuteIntent, int32_t(uint64_t key, const sptr &callerToken, const InsightIntentExecuteParam ¶m)); + MOCK_METHOD3(ExecuteInsightIntentDone, int32_t(const sptr &token, uint64_t intentId, + const InsightIntentExecuteResult &result)); public: std::string powerState_; static bool finishFlag_; @@ -342,6 +344,8 @@ public: MOCK_METHOD1(DetachAppDebug, int32_t(const std::string &bundleName)); MOCK_METHOD3(ExecuteIntent, int32_t(uint64_t key, const sptr &callerToken, const InsightIntentExecuteParam ¶m)); + MOCK_METHOD3(ExecuteInsightIntentDone, int32_t(const sptr &token, uint64_t intentId, + const InsightIntentExecuteResult &result)); public: std::string powerState_; static bool finishFlag_; 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 b3822553f99..873710dfc9b 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 @@ -130,6 +130,8 @@ public: MOCK_METHOD1(DetachAppDebug, int32_t(const std::string &bundleName)); MOCK_METHOD3(ExecuteIntent, int32_t(uint64_t key, const sptr &callerToken, const InsightIntentExecuteParam ¶m)); + MOCK_METHOD3(ExecuteInsightIntentDone, int32_t(const sptr &token, uint64_t intentId, + const InsightIntentExecuteResult &result)); private: bool DumpStateCalled_ = false; 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 7d27d095793..c6b970acf36 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 @@ -280,7 +280,9 @@ public: MOCK_METHOD1(DetachAppDebug, int32_t(const std::string &bundleName)); MOCK_METHOD3(ExecuteIntent, int32_t(uint64_t key, const sptr &callerToken, const InsightIntentExecuteParam ¶m)); - + MOCK_METHOD3(ExecuteInsightIntentDone, int32_t(const sptr &token, uint64_t intentId, + const InsightIntentExecuteResult &result)); + AbilityLifeCycleState curstate_ = AbilityLifeCycleState::ABILITY_STATE_INITIAL; sptr abilityScheduler_; // kit interface used to schedule ability life Want want_; 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 306222254b7..0c4e8dc7dd0 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 @@ -295,6 +295,8 @@ public: MOCK_METHOD1(DetachAppDebug, int32_t(const std::string &bundleName)); MOCK_METHOD3(ExecuteIntent, int32_t(uint64_t key, const sptr &callerToken, const InsightIntentExecuteParam ¶m)); + MOCK_METHOD3(ExecuteInsightIntentDone, int32_t(const sptr &token, uint64_t intentId, + const InsightIntentExecuteResult &result)); sptr abilityScheduler_ = nullptr; // kit interface used to schedule ability life Want want_; diff --git a/test/moduletest/mock/include/mock_ability_mgr_service.h b/test/moduletest/mock/include/mock_ability_mgr_service.h index 50d5a59391e..2b22033b676 100644 --- a/test/moduletest/mock/include/mock_ability_mgr_service.h +++ b/test/moduletest/mock/include/mock_ability_mgr_service.h @@ -262,6 +262,8 @@ public: MOCK_METHOD1(DetachAppDebug, int32_t(const std::string &bundleName)); MOCK_METHOD3(ExecuteIntent, int32_t(uint64_t key, const sptr &callerToken, const InsightIntentExecuteParam ¶m)); + MOCK_METHOD3(ExecuteInsightIntentDone, int32_t(const sptr &token, uint64_t intentId, + const InsightIntentExecuteResult &result)); private: Semaphore sem_; 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 35e0059f294..39d6b7aca2f 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 @@ -418,6 +418,8 @@ public: MOCK_METHOD1(DetachAppDebug, int32_t(const std::string &bundleName)); MOCK_METHOD3(ExecuteIntent, int32_t(uint64_t key, const sptr &callerToken, const InsightIntentExecuteParam ¶m)); + MOCK_METHOD3(ExecuteInsightIntentDone, int32_t(const sptr &token, uint64_t intentId, + const InsightIntentExecuteResult &result)); }; } // namespace AAFwk } // namespace OHOS 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 79e78fd55d6..b8f2752c373 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 @@ -402,6 +402,8 @@ public: MOCK_METHOD1(IsAbilityControllerStart, bool(const Want& want)); MOCK_METHOD3(ExecuteIntent, int32_t(uint64_t key, const sptr &callerToken, const InsightIntentExecuteParam ¶m)); + MOCK_METHOD3(ExecuteInsightIntentDone, int32_t(const sptr &token, uint64_t intentId, + const InsightIntentExecuteResult &result)); }; } // namespace AAFwk } // namespace OHOS 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 3efdae46001..1c71e8b896a 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 @@ -402,6 +402,8 @@ public: MOCK_METHOD1(IsAbilityControllerStart, bool(const Want& want)); MOCK_METHOD3(ExecuteIntent, int32_t(uint64_t key, const sptr &callerToken, const InsightIntentExecuteParam ¶m)); + MOCK_METHOD3(ExecuteInsightIntentDone, int32_t(const sptr &token, uint64_t intentId, + const InsightIntentExecuteResult &result)); }; } // namespace AAFwk } // namespace OHOS 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 b4fd794ff19..1138a6bdd53 100644 --- a/test/unittest/ability_manager_test/ability_manager_stub_mock.h +++ b/test/unittest/ability_manager_test/ability_manager_stub_mock.h @@ -402,6 +402,8 @@ public: MOCK_METHOD1(DetachAppDebug, int32_t(const std::string &bundleName)); MOCK_METHOD3(ExecuteIntent, int32_t(uint64_t key, const sptr &callerToken, const InsightIntentExecuteParam ¶m)); + MOCK_METHOD3(ExecuteInsightIntentDone, int32_t(const sptr &token, uint64_t intentId, + const InsightIntentExecuteResult &result)); }; } // namespace AAFwk } // namespace OHOS 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 4a90256f500..26c90c30bd6 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 @@ -393,6 +393,8 @@ public: MOCK_METHOD1(DetachAppDebug, int32_t(const std::string &bundleName)); MOCK_METHOD3(ExecuteIntent, int32_t(uint64_t key, const sptr &callerToken, const InsightIntentExecuteParam ¶m)); + MOCK_METHOD3(ExecuteInsightIntentDone, int32_t(const sptr &token, uint64_t intentId, + const InsightIntentExecuteResult &result)); }; } // namespace AAFwk } // namespace OHOS 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 38a0a58979f..2a8e620c889 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 @@ -271,6 +271,8 @@ public: MOCK_METHOD1(DetachAppDebug, int32_t(const std::string &bundleName)); MOCK_METHOD3(ExecuteIntent, int32_t(uint64_t key, const sptr &callerToken, const InsightIntentExecuteParam ¶m)); + MOCK_METHOD3(ExecuteInsightIntentDone, int32_t(const sptr &token, uint64_t intentId, + const InsightIntentExecuteResult &result)); AbilityLifeCycleState curstate_ = AbilityLifeCycleState::ABILITY_STATE_INITIAL; sptr abilityScheduler_; // kit interface used to schedule ability life diff --git a/tools/test/mock/mock_ability_manager_stub.h b/tools/test/mock/mock_ability_manager_stub.h index 5a75704d31a..9b9aec645d6 100644 --- a/tools/test/mock/mock_ability_manager_stub.h +++ b/tools/test/mock/mock_ability_manager_stub.h @@ -272,6 +272,8 @@ public: MOCK_METHOD1(DetachAppDebug, int32_t(const std::string &bundleName)); MOCK_METHOD3(ExecuteIntent, int32_t(uint64_t key, const sptr &callerToken, const InsightIntentExecuteParam ¶m)); + MOCK_METHOD3(ExecuteInsightIntentDone, int32_t(const sptr &token, uint64_t intentId, + const InsightIntentExecuteResult &result)); public: std::string powerState_; -- Gitee