From 80e4ba9e5ac2444ef1cdcbd4e4048d1fd11ea0ce Mon Sep 17 00:00:00 2001 From: savior-xzh Date: Tue, 11 Jun 2024 19:40:25 +0800 Subject: [PATCH] app clone index Signed-off-by: savior-xzh Change-Id: Ia0b847b8c0317c67dbdfe189c45469909422f4a3 --- .../include/system_dialog_scheduler.h | 8 ++-- .../src/implicit_start_processor.cpp | 41 ++++++++++--------- .../src/system_dialog_scheduler.cpp | 32 +++++++-------- .../ability_manager_service_dialog_test.cpp | 3 +- 4 files changed, 44 insertions(+), 40 deletions(-) diff --git a/services/abilitymgr/include/system_dialog_scheduler.h b/services/abilitymgr/include/system_dialog_scheduler.h index 064d3a2360..d4a6968762 100644 --- a/services/abilitymgr/include/system_dialog_scheduler.h +++ b/services/abilitymgr/include/system_dialog_scheduler.h @@ -70,11 +70,11 @@ public: explicit SystemDialogScheduler() = default; virtual ~SystemDialogScheduler() = default; - int GetSelectorDialogWantCommon(const std::vector &dialogAppInfos, Want &targetWant, - const sptr &callerToken); - int GetPcSelectorDialogWant(const std::vector &dialogAppInfos, Want &targetWant, + int GetSelectorDialogWantCommon(const std::vector &dialogAppInfos, Want &requestWant, + Want &targetWant, const sptr &callerToken); + int GetPcSelectorDialogWant(const std::vector &dialogAppInfos, Want &requestWant, Want &targetWant, const std::string &type, int32_t userId, const sptr &callerToken); - int GetSelectorDialogWant(const std::vector &dialogAppInfos, Want &targetWant, + int GetSelectorDialogWant(const std::vector &dialogAppInfos, Want &requestWant, Want &targetWant, const sptr &callerToken); Want GetTipsDialogWant(const sptr &callerToken); Want GetJumpInterceptorDialogWant(Want &targetWant); diff --git a/services/abilitymgr/src/implicit_start_processor.cpp b/services/abilitymgr/src/implicit_start_processor.cpp index f79620afd2..7c517a12fd 100644 --- a/services/abilitymgr/src/implicit_start_processor.cpp +++ b/services/abilitymgr/src/implicit_start_processor.cpp @@ -51,6 +51,7 @@ const int NFC_QUERY_LENGTH = 2; const std::string OPEN_LINK_APP_LINKING_ONLY = "appLinkingOnly"; const std::string HTTP_SCHEME_NAME = "http"; const std::string HTTPS_SCHEME_NAME = "https"; +const std::string APP_CLONE_INDEX = "ohos.extra.param.key.appCloneIndex"; const std::vector ImplicitStartProcessor::blackList = { std::vector::value_type(BLACK_ACTION_SELECT_DATA), @@ -93,6 +94,7 @@ int ImplicitStartProcessor::ImplicitStartAbility(AbilityRequest &request, int32_ CHECK_POINTER_AND_RETURN(sysDialogScheduler, ERR_INVALID_VALUE); std::vector dialogAppInfos; + request.want.RemoveParam(APP_CLONE_INDEX); auto ret = GenerateAbilityRequestByAction(userId, request, dialogAppInfos, false); if (ret != ERR_OK) { TAG_LOGE(AAFwkTag::ABILITYMGR, "generate ability request by action failed."); @@ -126,31 +128,31 @@ int ImplicitStartProcessor::ImplicitStartAbility(AbilityRequest &request, int32_ TAG_LOGI(AAFwkTag::ABILITYMGR, "hint dialog doesn't generate."); return ERR_IMPLICIT_START_ABILITY_FAIL; } - ret = sysDialogScheduler->GetSelectorDialogWant(dialogAppInfos, request.want, request.callerToken); + ret = sysDialogScheduler->GetSelectorDialogWant(dialogAppInfos, request.want, want, request.callerToken); if (ret != ERR_OK) { TAG_LOGE(AAFwkTag::ABILITYMGR, "GetSelectorDialogWant failed."); return ret; } - if (request.want.GetBoolParam("isCreateAppGallerySelector", false)) { - request.want.RemoveParam("isCreateAppGallerySelector"); - NotifyCreateModalDialog(request, request.want, userId, dialogAppInfos); + if (want.GetBoolParam("isCreateAppGallerySelector", false)) { + want.RemoveParam("isCreateAppGallerySelector"); + NotifyCreateModalDialog(request, want, userId, dialogAppInfos); return ERR_IMPLICIT_START_ABILITY_FAIL; } TAG_LOGE(AAFwkTag::ABILITYMGR, "implicit query ability infos failed, show tips dialog."); - want = sysDialogScheduler->GetTipsDialogWant(request.callerToken); - abilityMgr->StartAbility(want); + Want dialogWant = sysDialogScheduler->GetTipsDialogWant(request.callerToken); + abilityMgr->StartAbility(dialogWant); return ERR_IMPLICIT_START_ABILITY_FAIL; } else if (dialogAppInfos.size() == 0 && !AppUtils::GetInstance().IsSelectorDialogDefaultPossion()) { std::string type = MatchTypeAndUri(request.want); - ret = sysDialogScheduler->GetPcSelectorDialogWant(dialogAppInfos, request.want, type, + ret = sysDialogScheduler->GetPcSelectorDialogWant(dialogAppInfos, request.want, want, type, userId, request.callerToken); if (ret != ERR_OK) { TAG_LOGE(AAFwkTag::ABILITYMGR, "GetPcSelectorDialogWant failed."); return ret; } - if (request.want.GetBoolParam("isCreateAppGallerySelector", false)) { - request.want.RemoveParam("isCreateAppGallerySelector"); - NotifyCreateModalDialog(request, request.want, userId, dialogAppInfos); + if (want.GetBoolParam("isCreateAppGallerySelector", false)) { + want.RemoveParam("isCreateAppGallerySelector"); + NotifyCreateModalDialog(request, want, userId, dialogAppInfos); return ERR_IMPLICIT_START_ABILITY_FAIL; } std::vector dialogAllAppInfos; @@ -169,7 +171,7 @@ int ImplicitStartProcessor::ImplicitStartAbility(AbilityRequest &request, int32_ abilityMgr->StartAbility(dialogWant); return ERR_IMPLICIT_START_ABILITY_FAIL; } - ret = sysDialogScheduler->GetPcSelectorDialogWant(dialogAllAppInfos, request.want, + ret = sysDialogScheduler->GetPcSelectorDialogWant(dialogAllAppInfos, request.want, want, TYPE_ONLY_MATCH_WILDCARD, userId, request.callerToken); if (ret != ERR_OK) { TAG_LOGE(AAFwkTag::ABILITYMGR, "GetPcSelectorDialogWant failed."); @@ -193,14 +195,14 @@ int ImplicitStartProcessor::ImplicitStartAbility(AbilityRequest &request, int32_ if (AppUtils::GetInstance().IsSelectorDialogDefaultPossion()) { TAG_LOGI(AAFwkTag::ABILITYMGR, "ImplicitQueryInfos success, Multiple apps to choose."); - ret = sysDialogScheduler->GetSelectorDialogWant(dialogAppInfos, request.want, request.callerToken); + ret = sysDialogScheduler->GetSelectorDialogWant(dialogAppInfos, request.want, want, request.callerToken); if (ret != ERR_OK) { TAG_LOGE(AAFwkTag::ABILITYMGR, "GetSelectorDialogWant failed."); return ret; } - if (request.want.GetBoolParam("isCreateAppGallerySelector", false)) { - request.want.RemoveParam("isCreateAppGallerySelector"); - return NotifyCreateModalDialog(request, request.want, userId, dialogAppInfos); + if (want.GetBoolParam("isCreateAppGallerySelector", false)) { + want.RemoveParam("isCreateAppGallerySelector"); + return NotifyCreateModalDialog(request, want, userId, dialogAppInfos); } ret = abilityMgr->ImplicitStartAbilityAsCaller(request.want, request.callerToken, nullptr); // reset calling indentity @@ -211,14 +213,15 @@ int ImplicitStartProcessor::ImplicitStartAbility(AbilityRequest &request, int32_ TAG_LOGI(AAFwkTag::ABILITYMGR, "ImplicitQueryInfos success, Multiple apps to choose in pc."); std::string type = MatchTypeAndUri(request.want); - ret = sysDialogScheduler->GetPcSelectorDialogWant(dialogAppInfos, request.want, type, userId, request.callerToken); + ret = sysDialogScheduler->GetPcSelectorDialogWant(dialogAppInfos, request.want, want, + type, userId, request.callerToken); if (ret != ERR_OK) { TAG_LOGE(AAFwkTag::ABILITYMGR, "GetPcSelectorDialogWant failed."); return ret; } - if (request.want.GetBoolParam("isCreateAppGallerySelector", false)) { - request.want.RemoveParam("isCreateAppGallerySelector"); - return NotifyCreateModalDialog(request, request.want, userId, dialogAppInfos); + if (want.GetBoolParam("isCreateAppGallerySelector", false)) { + want.RemoveParam("isCreateAppGallerySelector"); + return NotifyCreateModalDialog(request, want, userId, dialogAppInfos); } ret = abilityMgr->ImplicitStartAbilityAsCaller(request.want, request.callerToken, nullptr); // reset calling indentity diff --git a/services/abilitymgr/src/system_dialog_scheduler.cpp b/services/abilitymgr/src/system_dialog_scheduler.cpp index c3e792fd3b..ec45ef3041 100644 --- a/services/abilitymgr/src/system_dialog_scheduler.cpp +++ b/services/abilitymgr/src/system_dialog_scheduler.cpp @@ -316,8 +316,8 @@ void SystemDialogScheduler::GetSelectorDialogPositionAndSize( lineNums, display->GetVirtualPixelRatio()); } -int SystemDialogScheduler::GetSelectorDialogWant(const std::vector &dialogAppInfos, Want &targetWant, - const sptr &callerToken) +int SystemDialogScheduler::GetSelectorDialogWant(const std::vector &dialogAppInfos, Want &requestWant, + Want &targetWant, const sptr &callerToken) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); TAG_LOGD(AAFwkTag::DIALOG, "GetSelectorDialogWant start"); @@ -326,11 +326,11 @@ int SystemDialogScheduler::GetSelectorDialogWant(const std::vector(dialogAppInfos.size())); std::string params = GetSelectorParams(dialogAppInfos); - targetWant.SetElementName(BUNDLE_NAME_DIALOG, ABILITY_NAME_SELECTOR_DIALOG); - targetWant.SetParam(DIALOG_POSITION, GetDialogPositionParams(portraitPosition)); - targetWant.SetParam(VERTICAL_SCREEN_DIALOG_POSITION, GetDialogPositionParams(landscapePosition)); - targetWant.SetParam(DIALOG_PARAMS, params); - return GetSelectorDialogWantCommon(dialogAppInfos, targetWant, callerToken); + requestWant.SetElementName(BUNDLE_NAME_DIALOG, ABILITY_NAME_SELECTOR_DIALOG); + requestWant.SetParam(DIALOG_POSITION, GetDialogPositionParams(portraitPosition)); + requestWant.SetParam(VERTICAL_SCREEN_DIALOG_POSITION, GetDialogPositionParams(landscapePosition)); + requestWant.SetParam(DIALOG_PARAMS, params); + return GetSelectorDialogWantCommon(dialogAppInfos, requestWant, targetWant, callerToken); } const std::string SystemDialogScheduler::GetSelectorParams(const std::vector &infos) const @@ -359,7 +359,7 @@ const std::string SystemDialogScheduler::GetSelectorParams(const std::vector &dialogAppInfos, +int SystemDialogScheduler::GetPcSelectorDialogWant(const std::vector &dialogAppInfos, Want &requestWant, Want &targetWant, const std::string &type, int32_t userId, const sptr &callerToken) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); @@ -367,11 +367,11 @@ int SystemDialogScheduler::GetPcSelectorDialogWant(const std::vector(dialogAppInfos.size())); - std::string params = GetPcSelectorParams(dialogAppInfos, type, userId, targetWant.GetAction()); - targetWant.SetElementName(BUNDLE_NAME_DIALOG, ABILITY_NAME_SELECTOR_DIALOG); - targetWant.SetParam(DIALOG_POSITION, GetDialogPositionParams(position)); - targetWant.SetParam(DIALOG_PARAMS, params); - return GetSelectorDialogWantCommon(dialogAppInfos, targetWant, callerToken); + std::string params = GetPcSelectorParams(dialogAppInfos, type, userId, requestWant.GetAction()); + requestWant.SetElementName(BUNDLE_NAME_DIALOG, ABILITY_NAME_SELECTOR_DIALOG); + requestWant.SetParam(DIALOG_POSITION, GetDialogPositionParams(position)); + requestWant.SetParam(DIALOG_PARAMS, params); + return GetSelectorDialogWantCommon(dialogAppInfos, requestWant, targetWant, callerToken); } const std::string SystemDialogScheduler::GetPcSelectorParams(const std::vector &infos, @@ -410,7 +410,7 @@ const std::string SystemDialogScheduler::GetPcSelectorParams(const std::vector &dialogAppInfos, - Want &targetWant, const sptr &callerToken) + Want &requestWant, Want &targetWant, const sptr &callerToken) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); TAG_LOGD(AAFwkTag::DIALOG, "GetSelectorDialogWantCommon start"); @@ -423,9 +423,9 @@ int SystemDialogScheduler::GetSelectorDialogWantCommon(const std::vectorGetAbilityInfo().extensionAbilityType)) { // SelectorDialog can't bind to the window of UIExtension, so set CALLER_TOKEN to null. - targetWant.RemoveParam(CALLER_TOKEN); + requestWant.RemoveParam(CALLER_TOKEN); } else { - targetWant.SetParam(CALLER_TOKEN, callerToken); + requestWant.SetParam(CALLER_TOKEN, callerToken); } } if (AppGalleryEnableUtil::IsEnableAppGallerySelector() && Rosen::SceneBoardJudgement::IsSceneBoardEnabled() diff --git a/test/unittest/ability_manager_service_dialog_test/ability_manager_service_dialog_test.cpp b/test/unittest/ability_manager_service_dialog_test/ability_manager_service_dialog_test.cpp index 67b576f151..1ec80a3c0d 100644 --- a/test/unittest/ability_manager_service_dialog_test/ability_manager_service_dialog_test.cpp +++ b/test/unittest/ability_manager_service_dialog_test/ability_manager_service_dialog_test.cpp @@ -116,8 +116,9 @@ HWTEST_F(AbilityMgrServiceDialogTest, AbilityMgrServiceDialog_0300, TestSize.Lev { TAG_LOGI(AAFwkTag::TEST, "AbilityMgrServiceDialog_0300 start"); std::vector dialogAppInfos; + Want requestWant; Want targetWant; - auto ret = systemDialogScheduler_->GetSelectorDialogWant(dialogAppInfos, targetWant, nullptr); + auto ret = systemDialogScheduler_->GetSelectorDialogWant(dialogAppInfos, requestWant, targetWant, nullptr); if (!Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { EXPECT_EQ(targetWant.GetElement().GetBundleName(), "com.ohos.amsdialog"); EXPECT_EQ(targetWant.GetElement().GetAbilityName(), "SelectorDialog");