app clone index

Signed-off-by: savior-xzh <xuzheheng2@huawei.com>
Change-Id: Ia0b847b8c0317c67dbdfe189c45469909422f4a3
This commit is contained in:
savior-xzh
2024-06-11 19:40:25 +08:00
parent 0f3a3a0a92
commit 80e4ba9e5a
4 changed files with 44 additions and 40 deletions
@@ -70,11 +70,11 @@ public:
explicit SystemDialogScheduler() = default;
virtual ~SystemDialogScheduler() = default;
int GetSelectorDialogWantCommon(const std::vector<DialogAppInfo> &dialogAppInfos, Want &targetWant,
const sptr<IRemoteObject> &callerToken);
int GetPcSelectorDialogWant(const std::vector<DialogAppInfo> &dialogAppInfos, Want &targetWant,
int GetSelectorDialogWantCommon(const std::vector<DialogAppInfo> &dialogAppInfos, Want &requestWant,
Want &targetWant, const sptr<IRemoteObject> &callerToken);
int GetPcSelectorDialogWant(const std::vector<DialogAppInfo> &dialogAppInfos, Want &requestWant, Want &targetWant,
const std::string &type, int32_t userId, const sptr<IRemoteObject> &callerToken);
int GetSelectorDialogWant(const std::vector<DialogAppInfo> &dialogAppInfos, Want &targetWant,
int GetSelectorDialogWant(const std::vector<DialogAppInfo> &dialogAppInfos, Want &requestWant, Want &targetWant,
const sptr<IRemoteObject> &callerToken);
Want GetTipsDialogWant(const sptr<IRemoteObject> &callerToken);
Want GetJumpInterceptorDialogWant(Want &targetWant);
@@ -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<std::string> ImplicitStartProcessor::blackList = {
std::vector<std::string>::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<DialogAppInfo> 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<DialogAppInfo> 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
@@ -316,8 +316,8 @@ void SystemDialogScheduler::GetSelectorDialogPositionAndSize(
lineNums, display->GetVirtualPixelRatio());
}
int SystemDialogScheduler::GetSelectorDialogWant(const std::vector<DialogAppInfo> &dialogAppInfos, Want &targetWant,
const sptr<IRemoteObject> &callerToken)
int SystemDialogScheduler::GetSelectorDialogWant(const std::vector<DialogAppInfo> &dialogAppInfos, Want &requestWant,
Want &targetWant, const sptr<IRemoteObject> &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<DialogAppInfo
GetSelectorDialogPositionAndSize(portraitPosition, landscapePosition, static_cast<int>(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<DialogAppInfo> &infos) const
@@ -359,7 +359,7 @@ const std::string SystemDialogScheduler::GetSelectorParams(const std::vector<Dia
return jsonObject.dump();
}
int SystemDialogScheduler::GetPcSelectorDialogWant(const std::vector<DialogAppInfo> &dialogAppInfos,
int SystemDialogScheduler::GetPcSelectorDialogWant(const std::vector<DialogAppInfo> &dialogAppInfos, Want &requestWant,
Want &targetWant, const std::string &type, int32_t userId, const sptr<IRemoteObject> &callerToken)
{
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
@@ -367,11 +367,11 @@ int SystemDialogScheduler::GetPcSelectorDialogWant(const std::vector<DialogAppIn
DialogPosition position;
GetDialogPositionAndSize(DialogType::DIALOG_SELECTOR, position, static_cast<int>(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<DialogAppInfo> &infos,
@@ -410,7 +410,7 @@ const std::string SystemDialogScheduler::GetPcSelectorParams(const std::vector<D
}
int SystemDialogScheduler::GetSelectorDialogWantCommon(const std::vector<DialogAppInfo> &dialogAppInfos,
Want &targetWant, const sptr<IRemoteObject> &callerToken)
Want &requestWant, Want &targetWant, const sptr<IRemoteObject> &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::vector<DialogA
}
if (abilityRecord && UIExtensionUtils::IsUIExtension(abilityRecord->GetAbilityInfo().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()
@@ -116,8 +116,9 @@ HWTEST_F(AbilityMgrServiceDialogTest, AbilityMgrServiceDialog_0300, TestSize.Lev
{
TAG_LOGI(AAFwkTag::TEST, "AbilityMgrServiceDialog_0300 start");
std::vector<DialogAppInfo> 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");