!11873 分身选择框场景不再重复校验调用方

Merge pull request !11873 from 于文泽/index
This commit is contained in:
openharmony_ci
2024-12-06 07:25:51 +00:00
committed by Gitee
4 changed files with 61 additions and 57 deletions
@@ -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<IRemoteObject> 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,
@@ -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<IRemoteObject> 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 &parameters, std::vector<DialogAppInfo> &dialogAppInfos, bool isSelector);
const AAFwk::WantParams &parameters, std::vector<DialogAppInfo> &dialogAppInfos, SelectorType type);
void GenerateCallerAbilityInfo(AbilityRequest &abilityRequest, DialogAbilityInfo &callerAbilityInfo);
@@ -102,7 +103,7 @@ private:
std::vector<DialogAbilityInfo> &targetAbilityInfos);
void GenerateDialogCallerInfo(AbilityRequest &abilityRequest, int32_t userId,
std::shared_ptr<DialogCallerInfo> dialogCallerInfo, bool isSelector);
std::shared_ptr<DialogCallerInfo> dialogCallerInfo, SelectorType type);
int CreateModalDialogCommon(const Want &replaceWant, sptr<IRemoteObject> callerToken,
const std::string &dialogSessionId);
@@ -786,7 +786,7 @@ int AbilityManagerService::ImplicitStartAbilityAsCaller(const Want &want, const
}
int AbilityManagerService::StartAbilityAsCallerDetails(const Want &want, const sptr<IRemoteObject> &callerToken,
sptr<IRemoteObject> asCallerSourceToken, int32_t userId, int requestCode, bool isImplicit)
sptr<IRemoteObject> 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 &params, int
int AbilityManagerService::StartAbilityWrap(const Want &want, const sptr<IRemoteObject> &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 &>(want));
@@ -905,9 +905,8 @@ int AbilityManagerService::StartAbilityWrap(const Want &want, const sptr<IRemote
return result;
}
return StartAbilityInner(want, callerToken,
requestCode, isPendingWantCaller, userId, isStartAsCaller, specifyToken, isForegroundToRestartApp, isImplicit,
isUIAbilityOnly);
return StartAbilityInner(want, callerToken, requestCode, isPendingWantCaller, userId, isStartAsCaller, specifyToken,
isForegroundToRestartApp, isImplicit, isUIAbilityOnly, isAppCloneSelector);
}
void AbilityManagerService::SetReserveInfo(const std::string &linkString, AbilityRequest& abilityRequest)
@@ -1017,7 +1016,7 @@ int AbilityManagerService::CheckCallPermission(const Want& want, const AppExecFw
int AbilityManagerService::StartAbilityInner(const Want &want, const sptr<IRemoteObject> &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<IRemot
return ERR_STATIC_CFG_PERMISSION;
}
result = CheckCallPermission(want, abilityInfo, abilityRequest, isForegroundToRestartApp,
isSendDialogResult, specifyTokenId, callerBundleName);
if (result != ERR_OK) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "checkCallPermission error, result:%{public}d", result);
return result;
if (!isAppCloneSelector) {
result = CheckCallPermission(want, abilityInfo, abilityRequest, isForegroundToRestartApp,
isSendDialogResult, specifyTokenId, callerBundleName);
if (result != ERR_OK) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "checkCallPermission error, result:%{public}d", result);
return result;
}
Want newWant = abilityRequest.want;
AbilityInterceptorParam afterCheckParam = AbilityInterceptorParam(newWant, requestCode, GetUserId(),
true, callerToken, std::make_shared<AppExecFwk::AbilityInfo>(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<AppExecFwk::AbilityInfo>(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);
@@ -186,11 +186,11 @@ void DialogSessionManager::GenerateJumpTargetAbilityInfos(AbilityRequest &abilit
}
void DialogSessionManager::GenerateDialogCallerInfo(AbilityRequest &abilityRequest, int32_t userId,
std::shared_ptr<DialogCallerInfo> dialogCallerInfo, bool isSelector)
std::shared_ptr<DialogCallerInfo> 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 &parameters, std::vector<DialogAppInfo> &dialogAppInfos, bool isSelector)
const AAFwk::WantParams &parameters, std::vector<DialogAppInfo> &dialogAppInfos, SelectorType type)
{
auto dialogSessionInfo = sptr<DialogSessionInfo>::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> dialogCallerInfo = std::make_shared<DialogCallerInfo>();
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<DialogAppInfo> 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<int>(SelectorType::APP_CLONR_SELECTOR)));
AAFwk::Integer::Box(static_cast<int>(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;