diff --git a/services/abilitymgr/include/ability_manager_service.h b/services/abilitymgr/include/ability_manager_service.h index a5954f683a..d6d61fd200 100644 --- a/services/abilitymgr/include/ability_manager_service.h +++ b/services/abilitymgr/include/ability_manager_service.h @@ -1028,7 +1028,8 @@ public: uint32_t specifyTokenId = 0, bool isForegroundToRestartApp = false, bool isImplicit = false, - bool isUIAbilityOnly = false); + bool isUIAbilityOnly = false, + bool isAppCloneSelector = false); int StartAbilityInner( const Want &want, @@ -1040,7 +1041,8 @@ public: uint32_t specifyTokenId = 0, bool isForegroundToRestartApp = false, bool isImplicit = false, - bool isUIAbilityOnly = false); + bool isUIAbilityOnly = false, + bool isAppCloneSelector = false); int32_t StartExtensionAbilityInner( const Want &want, @@ -1115,7 +1117,8 @@ public: sptr asCallerSourceToken, int32_t userId = DEFAULT_INVAL_VALUE, int requestCode = DEFAULT_INVAL_VALUE, - bool isImplicit = false); + bool isImplicit = false, + bool isAppCloneSelector = false); int ImplicitStartAbilityAsCaller( const Want &want, diff --git a/services/abilitymgr/include/dialog_session/dialog_session_manager.h b/services/abilitymgr/include/dialog_session/dialog_session_manager.h index c0249e19c4..c194d5fa43 100644 --- a/services/abilitymgr/include/dialog_session/dialog_session_manager.h +++ b/services/abilitymgr/include/dialog_session/dialog_session_manager.h @@ -30,17 +30,18 @@ namespace OHOS { namespace AAFwk { +enum class SelectorType { + WITHOUT_SELECTOR = -1, + IMPLICIT_START_SELECTOR = 0, + APP_CLONE_SELECTOR = 1 +}; + struct DialogCallerInfo { int32_t userId = -1; int requestCode = -1; sptr callerToken; Want targetWant; - bool isSelector = false; -}; - -enum class SelectorType { - IMPLICIT_START_SELECTOR = 0, - APP_CLONR_SELECTOR = 1 + SelectorType type = SelectorType::WITHOUT_SELECTOR; }; struct StartupSessionInfo { @@ -91,7 +92,7 @@ private: void ClearAllDialogContexts(); std::string GenerateDialogSessionRecordCommon(AbilityRequest &abilityRequest, int32_t userId, - const AAFwk::WantParams ¶meters, std::vector &dialogAppInfos, bool isSelector); + const AAFwk::WantParams ¶meters, std::vector &dialogAppInfos, SelectorType type); void GenerateCallerAbilityInfo(AbilityRequest &abilityRequest, DialogAbilityInfo &callerAbilityInfo); @@ -102,7 +103,7 @@ private: std::vector &targetAbilityInfos); void GenerateDialogCallerInfo(AbilityRequest &abilityRequest, int32_t userId, - std::shared_ptr dialogCallerInfo, bool isSelector); + std::shared_ptr dialogCallerInfo, SelectorType type); int CreateModalDialogCommon(const Want &replaceWant, sptr callerToken, const std::string &dialogSessionId); diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index b0630d58c2..371e72c1d2 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -786,7 +786,7 @@ int AbilityManagerService::ImplicitStartAbilityAsCaller(const Want &want, const } int AbilityManagerService::StartAbilityAsCallerDetails(const Want &want, const sptr &callerToken, - sptr asCallerSourceToken, int32_t userId, int requestCode, bool isImplicit) + sptr asCallerSourceToken, int32_t userId, int requestCode, bool isImplicit, bool isAppCloneSelector) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); CHECK_CALLER_IS_SYSTEM_APP; @@ -814,7 +814,7 @@ int AbilityManagerService::StartAbilityAsCallerDetails(const Want &want, const s AbilityUtil::AddAbilityJumpRuleToBms(callerPkg, targetPkg, GetUserId()); } int32_t ret = StartAbilityWrap(newWant, callerToken, requestCode, false, userId, true, - 0, false, isImplicit); + 0, false, isImplicit, false, isAppCloneSelector); if (ret != ERR_OK) { eventInfo.errCode = ret; SendAbilityEvent(EventName::START_ABILITY_ERROR, HiSysEventType::FAULT, eventInfo); @@ -890,7 +890,7 @@ bool AbilityManagerService::StartAbilityInChain(StartAbilityParams ¶ms, int int AbilityManagerService::StartAbilityWrap(const Want &want, const sptr &callerToken, int requestCode, bool isPendingWantCaller, int32_t userId, bool isStartAsCaller, uint32_t specifyToken, - bool isForegroundToRestartApp, bool isImplicit, bool isUIAbilityOnly) + bool isForegroundToRestartApp, bool isImplicit, bool isUIAbilityOnly, bool isAppCloneSelector) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); StartAbilityParams startParams(const_cast(want)); @@ -905,9 +905,8 @@ int AbilityManagerService::StartAbilityWrap(const Want &want, const sptr &callerToken, int requestCode, bool isPendingWantCaller, int32_t userId, bool isStartAsCaller, uint32_t specifyTokenId, - bool isForegroundToRestartApp, bool isImplicit, bool isUIAbilityOnly) + bool isForegroundToRestartApp, bool isImplicit, bool isUIAbilityOnly, bool isAppCloneSelector) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); std::string dialogSessionId = want.GetStringParam("dialogSessionId"); @@ -1198,35 +1197,36 @@ int AbilityManagerService::StartAbilityInner(const Want &want, const sptr(abilityInfo), isStartAsCaller, appIndex); + result = afterCheckExecuter_ == nullptr ? ERR_INVALID_VALUE : + afterCheckExecuter_->DoProcess(afterCheckParam); + bool isReplaceWantExist = newWant.GetBoolParam("queryWantFromErms", false); + newWant.RemoveParam("queryWantFromErms"); + if (result != ERR_OK && isReplaceWantExist == false) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "doProcess failed or replaceWant absent"); + return result; + } + #ifdef SUPPORT_SCREEN + if (result != ERR_OK && isReplaceWantExist && callerBundleName != BUNDLE_NAME_DIALOG) { + return DialogSessionManager::GetInstance().HandleErmsResult(abilityRequest, GetUserId(), newWant); + } + if (result == ERR_OK && + DialogSessionManager::GetInstance().IsCreateCloneSelectorDialog(abilityInfo.bundleName, GetUserId())) { + TAG_LOGI(AAFwkTag::ABILITYMGR, "create clone selector dialog"); + return CreateCloneSelectorDialog(abilityRequest, GetUserId()); + } + #endif // SUPPORT_SCREEN } - Want newWant = abilityRequest.want; - AbilityInterceptorParam afterCheckParam = AbilityInterceptorParam(newWant, requestCode, GetUserId(), - true, callerToken, std::make_shared(abilityInfo), isStartAsCaller, appIndex); - result = afterCheckExecuter_ == nullptr ? ERR_INVALID_VALUE : - afterCheckExecuter_->DoProcess(afterCheckParam); - bool isReplaceWantExist = newWant.GetBoolParam("queryWantFromErms", false); - newWant.RemoveParam("queryWantFromErms"); - if (result != ERR_OK && isReplaceWantExist == false) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "doProcess failed or replaceWant absent"); - return result; - } -#ifdef SUPPORT_SCREEN - if (result != ERR_OK && isReplaceWantExist && callerBundleName != BUNDLE_NAME_DIALOG) { - return DialogSessionManager::GetInstance().HandleErmsResult(abilityRequest, GetUserId(), newWant); - } - if (result == ERR_OK && - DialogSessionManager::GetInstance().IsCreateCloneSelectorDialog(abilityInfo.bundleName, GetUserId())) { - TAG_LOGI(AAFwkTag::ABILITYMGR, "create clone selector dialog"); - return CreateCloneSelectorDialog(abilityRequest, GetUserId()); - } -#endif // SUPPORT_SCREEN - if (!AbilityUtil::IsSystemDialogAbility(abilityInfo.bundleName, abilityInfo.name)) { TAG_LOGD(AAFwkTag::ABILITYMGR, "PreLoadAppDataAbilities:%{public}s.", abilityInfo.bundleName.c_str()); result = PreLoadAppDataAbilities(abilityInfo.bundleName, validUserId); diff --git a/services/abilitymgr/src/dialog_session/dialog_session_manager.cpp b/services/abilitymgr/src/dialog_session/dialog_session_manager.cpp index df58225376..ef05313bb7 100644 --- a/services/abilitymgr/src/dialog_session/dialog_session_manager.cpp +++ b/services/abilitymgr/src/dialog_session/dialog_session_manager.cpp @@ -186,11 +186,11 @@ void DialogSessionManager::GenerateJumpTargetAbilityInfos(AbilityRequest &abilit } void DialogSessionManager::GenerateDialogCallerInfo(AbilityRequest &abilityRequest, int32_t userId, - std::shared_ptr dialogCallerInfo, bool isSelector) + std::shared_ptr dialogCallerInfo, SelectorType type) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); CHECK_POINTER(dialogCallerInfo); - dialogCallerInfo->isSelector = isSelector; + dialogCallerInfo->type = type; dialogCallerInfo->callerToken = abilityRequest.callerToken; dialogCallerInfo->requestCode = abilityRequest.requestCode; dialogCallerInfo->targetWant = abilityRequest.want; @@ -216,7 +216,7 @@ int DialogSessionManager::SendDialogResult(const Want &want, const std::string & } auto targetWant = dialogCallerInfo->targetWant; targetWant.SetElement(want.GetElement()); - targetWant.SetParam("isSelector", dialogCallerInfo->isSelector); + targetWant.SetParam("isSelector", dialogCallerInfo->type != SelectorType::WITHOUT_SELECTOR); targetWant.SetParam(DIALOG_SESSION_ID, dialogSessionId); if (want.HasParameter(AAFwk::Want::PARAM_APP_CLONE_INDEX_KEY)) { int32_t appIndex = want.GetIntParam(AAFwk::Want::PARAM_APP_CLONE_INDEX_KEY, 0); @@ -235,8 +235,8 @@ int DialogSessionManager::SendDialogResult(const Want &want, const std::string & TAG_LOGE(AAFwkTag::ABILITYMGR, "abilityMgr null"); return INNER_ERR; } - int ret = abilityMgr->StartAbilityAsCaller(targetWant, callerToken, callerToken, dialogCallerInfo->userId, - dialogCallerInfo->requestCode); + int ret = abilityMgr->StartAbilityAsCallerDetails(targetWant, callerToken, callerToken, dialogCallerInfo->userId, + dialogCallerInfo->requestCode, false, dialogCallerInfo->type == SelectorType::APP_CLONE_SELECTOR); if (ret == ERR_OK) { ClearDialogContext(dialogSessionId); abilityMgr->RemoveSelectorIdentity(dialogCallerInfo->targetWant.GetIntParam(Want::PARAM_RESV_CALLER_TOKEN, 0)); @@ -260,14 +260,14 @@ int32_t DialogSessionManager::NotifySCBToRecoveryAfterInterception(const std::st } std::string DialogSessionManager::GenerateDialogSessionRecordCommon(AbilityRequest &abilityRequest, int32_t userId, - const AAFwk::WantParams ¶meters, std::vector &dialogAppInfos, bool isSelector) + const AAFwk::WantParams ¶meters, std::vector &dialogAppInfos, SelectorType type) { auto dialogSessionInfo = sptr::MakeSptr(); CHECK_POINTER_AND_RETURN(dialogSessionInfo, ""); GenerateCallerAbilityInfo(abilityRequest, dialogSessionInfo->callerAbilityInfo); - if (isSelector) { + if (type != SelectorType::WITHOUT_SELECTOR) { GenerateSelectorTargetAbilityInfos(dialogAppInfos, dialogSessionInfo->targetAbilityInfos); } else { GenerateJumpTargetAbilityInfos(abilityRequest, dialogSessionInfo->targetAbilityInfos); @@ -276,7 +276,7 @@ std::string DialogSessionManager::GenerateDialogSessionRecordCommon(AbilityReque dialogSessionInfo->parameters = parameters; std::shared_ptr dialogCallerInfo = std::make_shared(); - GenerateDialogCallerInfo(abilityRequest, userId, dialogCallerInfo, isSelector); + GenerateDialogCallerInfo(abilityRequest, userId, dialogCallerInfo, type); std::string dialogSessionId = GenerateDialogSessionId(); SetDialogSessionInfo(dialogSessionId, dialogSessionInfo, dialogCallerInfo); @@ -296,7 +296,7 @@ int DialogSessionManager::CreateJumpModalDialog(AbilityRequest &abilityRequest, std::vector dialogAppInfos; std::string dialogSessionId = GenerateDialogSessionRecordCommon(abilityRequest, userId, parameters, - dialogAppInfos, false); + dialogAppInfos, SelectorType::WITHOUT_SELECTOR); if (dialogSessionId == "") { TAG_LOGE(AAFwkTag::ABILITYMGR, "generation failed"); return ERR_INVALID_VALUE; @@ -325,7 +325,7 @@ int DialogSessionManager::CreateImplicitSelectorModalDialog(AbilityRequest &abil abilityRequest.want.GetBoolParam("ohos.ability.params.showDefaultPicker", false)); std::string dialogSessionId = GenerateDialogSessionRecordCommon(abilityRequest, userId, sessionWant.GetParams(), - dialogAppInfos, true); + dialogAppInfos, SelectorType::IMPLICIT_START_SELECTOR); if (dialogSessionId == "") { TAG_LOGE(AAFwkTag::ABILITYMGR, "generation failed"); return ERR_INVALID_VALUE; @@ -343,13 +343,13 @@ int DialogSessionManager::CreateCloneSelectorModalDialog(AbilityRequest &ability parameters.SetParam("deviceType", AAFwk::String::Box(OHOS::system::GetDeviceType())); parameters.SetParam("userId", AAFwk::Integer::Box(userId)); parameters.SetParam("appselector.selectorType", - AAFwk::Integer::Box(static_cast(SelectorType::APP_CLONR_SELECTOR))); + AAFwk::Integer::Box(static_cast(SelectorType::APP_CLONE_SELECTOR))); if (replaceWant != "") { parameters.SetParam("ecological.replaceWant", AAFwk::String::Box(replaceWant)); } std::string dialogSessionId = GenerateDialogSessionRecordCommon(abilityRequest, userId, parameters, - dialogAppInfos, true); + dialogAppInfos, SelectorType::APP_CLONE_SELECTOR); if (dialogSessionId == "") { TAG_LOGE(AAFwkTag::ABILITYMGR, "generation failed"); return ERR_INVALID_VALUE;