指定备选主控进程SpecifiedUIAbility场景优化

Signed-off-by: sty <songtianyu10@huawei.com>
Change-Id: I1d16ecaa3b76baed0f0dac7857e7c3a414d8ad5c
This commit is contained in:
sty
2025-06-26 15:12:19 +08:00
parent a59021a3c2
commit b0c8a74fdd
19 changed files with 56 additions and 24 deletions
@@ -40,7 +40,8 @@ public:
*/
virtual void OnTimeoutResponse(int32_t requestId) = 0;
virtual void OnNewProcessRequestResponse(const std::string &flag, int32_t requestId) = 0;
virtual void OnNewProcessRequestResponse(const std::string &flag,
int32_t requestId, const std::string &callerProcessName = "") = 0;
virtual void OnNewProcessRequestTimeoutResponse(int32_t requestId) = 0;
@@ -40,7 +40,8 @@ public:
*/
virtual void OnTimeoutResponse(int32_t requestId) override;
virtual void OnNewProcessRequestResponse(const std::string &flag, int32_t requestId = 0) override;
virtual void OnNewProcessRequestResponse(const std::string &flag,
int32_t requestId = 0, const std::string &callerProcessName = "") override;
virtual void OnNewProcessRequestTimeoutResponse(int32_t requestId) override;
@@ -88,7 +88,8 @@ int32_t StartSpecifiedAbilityResponseProxy::SendTransactCmd(uint32_t code, Messa
return remote->SendRequest(code, data, reply, option);
}
void StartSpecifiedAbilityResponseProxy::OnNewProcessRequestResponse(const std::string &flag, int32_t requestId)
void StartSpecifiedAbilityResponseProxy::OnNewProcessRequestResponse(const std::string &flag,
int32_t requestId, const std::string &callerProcessName)
{
TAG_LOGD(AAFwkTag::APPMGR, "On satrt specified process response by proxy.");
MessageParcel data;
@@ -97,7 +98,7 @@ void StartSpecifiedAbilityResponseProxy::OnNewProcessRequestResponse(const std::
if (!WriteInterfaceToken(data)) {
return;
}
if (!data.WriteString(flag) || !data.WriteInt32(requestId)) {
if (!data.WriteString(flag) || !data.WriteInt32(requestId) || !data.WriteString(callerProcessName)) {
TAG_LOGE(AAFwkTag::APPMGR, "Write data failed.");
return;
}
@@ -44,7 +44,9 @@ int32_t StartSpecifiedAbilityResponseStub::HandleOnTimeoutResponse(MessageParcel
int32_t StartSpecifiedAbilityResponseStub::HandleOnNewProcessRequestResponse(MessageParcel &data, MessageParcel &reply)
{
auto flag = Str16ToStr8(data.ReadString16());
OnNewProcessRequestResponse(flag, data.ReadInt32());
auto requestId = data.ReadInt32();
auto callerProcessName = Str16ToStr8(data.ReadString16());
OnNewProcessRequestResponse(flag, requestId, callerProcessName);
return NO_ERROR;
}
@@ -1168,7 +1168,8 @@ public:
void OnAcceptWantResponse(const AAFwk::Want &want, const std::string &flag, int32_t requestId);
void OnStartSpecifiedAbilityTimeoutResponse(int32_t requestId);
void OnStartSpecifiedProcessResponse(const std::string &flag, int32_t requestId = 0);
void OnStartSpecifiedProcessResponse(const std::string &flag, int32_t requestId = 0,
const std::string &callerProcessName = "");
void OnStartSpecifiedProcessTimeoutResponse(int32_t requestId);
void OnStartSpecifiedFailed(int32_t requestId);
+2 -1
View File
@@ -131,7 +131,8 @@ public:
int32_t requestId) override;
virtual void OnTimeoutResponse(int32_t requestId) override;
virtual void OnNewProcessRequestResponse(const std::string &flag, int32_t requestId) override;
virtual void OnNewProcessRequestResponse(const std::string &flag, int32_t requestId,
const std::string &callerProcessName = "") override;
virtual void OnNewProcessRequestTimeoutResponse(int32_t requestId) override;
virtual void OnStartSpecifiedFailed(int32_t requestId) override;
@@ -206,7 +206,8 @@ public:
*
* @param requestId target ability requestId.
*/
void OnStartSpecifiedProcessResponse(const std::string &flag, int32_t requestId);
void OnStartSpecifiedProcessResponse(const std::string &flag, int32_t requestId,
const std::string &callerProcessName = "");
/**
* OnStartSpecifiedAbilityTimeoutResponse.
@@ -8468,7 +8468,8 @@ void AbilityManagerService::OnStartSpecifiedAbilityTimeoutResponse(int32_t reque
missionListManager->OnStartSpecifiedAbilityTimeoutResponse();
}
void AbilityManagerService::OnStartSpecifiedProcessResponse(const std::string &flag, int32_t requestId)
void AbilityManagerService::OnStartSpecifiedProcessResponse(const std::string &flag, int32_t requestId,
const std::string &callerProcessName)
{
TAG_LOGD(AAFwkTag::ABILITYMGR, "flag = %{public}s", flag.c_str());
auto connectManager = GetCurrentConnectManager();
@@ -8482,7 +8483,7 @@ void AbilityManagerService::OnStartSpecifiedProcessResponse(const std::string &f
if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
auto uiAbilityManager = GetCurrentUIAbilityManager();
CHECK_POINTER(uiAbilityManager);
uiAbilityManager->OnStartSpecifiedProcessResponse(flag, requestId);
uiAbilityManager->OnStartSpecifiedProcessResponse(flag, requestId, callerProcessName);
return;
}
}
+4 -2
View File
@@ -410,9 +410,11 @@ void AppScheduler::StartSpecifiedProcess(
IN_PROCESS_CALL_WITHOUT_RET(appMgrClient_->StartSpecifiedProcess(want, abilityInfo, requestId, customProcess));
}
void StartSpecifiedAbilityResponse::OnNewProcessRequestResponse(const std::string &flag, int32_t requestId)
void StartSpecifiedAbilityResponse::OnNewProcessRequestResponse(const std::string &flag, int32_t requestId,
const std::string &callerProcessName)
{
DelayedSingleton<AbilityManagerService>::GetInstance()->OnStartSpecifiedProcessResponse(flag, requestId);
DelayedSingleton<AbilityManagerService>::GetInstance()->OnStartSpecifiedProcessResponse(flag, requestId,
callerProcessName);
}
void StartSpecifiedAbilityResponse::OnNewProcessRequestTimeoutResponse(int32_t requestId)
@@ -59,6 +59,7 @@ constexpr const char* PARAM_SPECIFIED_PROCESS_FLAG = "ohoSpecifiedProcessFlag";
constexpr const char* DMS_PROCESS_NAME = "distributedsched";
constexpr const char* DMS_PERSISTENT_ID = "ohos.dms.persistentId";
constexpr const char* IS_SHELL_CALL = "isShellCall";
constexpr const char* SPECIFED_PROCESS_CALLER_PROCESS = "ohoSpecifiedProcessCallerProcess";
#ifdef SUPPORT_ASAN
constexpr int KILL_TIMEOUT_MULTIPLE = 45;
#else
@@ -2183,7 +2184,8 @@ void UIAbilityLifecycleManager::OnStartSpecifiedFailed(int32_t requestId)
}
}
void UIAbilityLifecycleManager::OnStartSpecifiedProcessResponse(const std::string &flag, int32_t requestId)
void UIAbilityLifecycleManager::OnStartSpecifiedProcessResponse(const std::string &flag, int32_t requestId,
const std::string &callerProcessName)
{
TAG_LOGI(AAFwkTag::ABILITYMGR, "OnStartSpecifiedProcessResponse, %{public}d", requestId);
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
@@ -2197,8 +2199,11 @@ void UIAbilityLifecycleManager::OnStartSpecifiedProcessResponse(const std::strin
auto &abilityRequest = request->abilityRequest;
abilityRequest.want.SetParam(PARAM_SPECIFIED_PROCESS_FLAG, flag);
if (abilityRequest.abilityInfo.launchMode == AppExecFwk::LaunchMode::SPECIFIED) {
abilityRequest.want.RemoveParam(SPECIFED_PROCESS_CALLER_PROCESS);
abilityRequest.want.SetParam(SPECIFED_PROCESS_CALLER_PROCESS, callerProcessName);
request->specifiedProcessState = SpecifiedProcessState::STATE_ABILITY;
StartSpecifiedRequest(*request);
abilityRequest.want.RemoveParam(SPECIFED_PROCESS_CALLER_PROCESS);
return;
}
auto nextRequest = PopAndGetNextSpecified(requestId);
+11 -3
View File
@@ -189,6 +189,7 @@ constexpr const char* PERMISSION_PROTECT_SCREEN_LOCK_DATA = "ohos.permission.PRO
constexpr const char* PERMISSION_TEMP_JIT_ALLOW = "TEMPJITALLOW";
constexpr const char* TARGET_UID_KEY = "ohos.aafwk.param.targetUid";
constexpr const char* REUSING_WINDOW = "ohos.ability_runtime.reusing_window";
constexpr const char* SPECIFED_PROCESS_CALLER_PROCESS = "ohoSpecifiedProcessCallerProcess";
constexpr const int32_t KILL_PROCESS_BY_USER_INTERVAL = 20;
constexpr const int32_t KILL_PROCESS_BY_USER_DELAY_BASE = 500;
constexpr const int64_t PRELOAD_FREEZE_TIMEOUT = 11000;
@@ -5385,9 +5386,15 @@ void AppMgrServiceInner::StartSpecifiedAbility(const AAFwk::Want &want, const Ap
return;
}
std::string processName;
std::string specifiedProcessFlag = GetSpecifiedProcessFlag(abilityInfo, want);
auto abilityInfoPtr = std::make_shared<AbilityInfo>(abilityInfo);
MakeProcessName(abilityInfoPtr, appInfo, hapModuleInfo, appIndex, "", processName, false);
std::string processName;
if (specifiedProcessFlag == "") {
MakeProcessName(abilityInfoPtr, appInfo, hapModuleInfo, appIndex, "", processName, false);
} else {
processName = want.GetStringParam(SPECIFED_PROCESS_CALLER_PROCESS);
const_cast<AAFwk::Want&>(want).RemoveParam(SPECIFED_PROCESS_CALLER_PROCESS);
}
bool isExtensionSandBox = IsIsolateExtensionSandBox(abilityInfoPtr, hapModuleInfo);
std::vector<HapModuleInfo> hapModules;
@@ -5541,8 +5548,9 @@ void AppMgrServiceInner::ScheduleNewProcessRequestDone(
appRecord->ScheduleNewProcessRequestDone();
appRecord->ResetNewProcessRequest();
const std::string callerProcessName = appRecord->GetProcessName();
if (startSpecifiedAbilityResponse_) {
startSpecifiedAbilityResponse_->OnNewProcessRequestResponse(flag, requestId);
startSpecifiedAbilityResponse_->OnNewProcessRequestResponse(flag, requestId, callerProcessName);
}
appRecord->ResetNewProcessRequest();
}
@@ -215,7 +215,8 @@ public:
*
* @param requestId target ability requestId.
*/
void OnStartSpecifiedProcessResponse(const std::string &flag, int32_t requestId);
void OnStartSpecifiedProcessResponse(const std::string &flag, int32_t requestId,
const std::string &callerProcessName = "");
/**
* OnStartSpecifiedAbilityTimeoutResponse.
@@ -408,7 +408,8 @@ void UIAbilityLifecycleManager::OnStartSpecifiedFailed(int32_t requestId)
{
}
void UIAbilityLifecycleManager::OnStartSpecifiedProcessResponse(const std::string &flag, int32_t requestId)
void UIAbilityLifecycleManager::OnStartSpecifiedProcessResponse(const std::string &flag, int32_t requestId,
const std::string &callerProcessName = "")
{
}
@@ -215,7 +215,8 @@ public:
*
* @param requestId target ability requestId.
*/
void OnStartSpecifiedProcessResponse(const std::string &flag, int32_t requestId);
void OnStartSpecifiedProcessResponse(const std::string &flag, int32_t requestId,
const std::string &callerProcessName = "");
/**
* OnStartSpecifiedAbilityTimeoutResponse.
@@ -411,7 +411,8 @@ void UIAbilityLifecycleManager::OnStartSpecifiedFailed(int32_t requestId)
{
}
void UIAbilityLifecycleManager::OnStartSpecifiedProcessResponse(const std::string &flag, int32_t requestId)
void UIAbilityLifecycleManager::OnStartSpecifiedProcessResponse(const std::string &flag, int32_t requestId,
const std::string &callerProcessName)
{
}
@@ -125,7 +125,8 @@ public:
{}
void OnTimeoutResponse(int32_t requestId) override
{}
void OnNewProcessRequestResponse(const std::string &flag, int32_t requestId) override
void OnNewProcessRequestResponse(const std::string &flag, int32_t requestId,
const std::string &callerProcessName) override
{}
void OnNewProcessRequestTimeoutResponse(int32_t requestId) override
{}
@@ -88,7 +88,8 @@ public:
{}
void OnTimeoutResponse(int32_t requestId) override
{}
void OnNewProcessRequestResponse(const std::string &flag, int32_t requestId) override
void OnNewProcessRequestResponse(const std::string &flag, int32_t requestId,
const std::string &callerProcessName) override
{}
void OnNewProcessRequestTimeoutResponse(int32_t requestId) override
{}
@@ -59,7 +59,8 @@ public:
{}
void OnTimeoutResponse(int32_t requestId) override
{}
void OnNewProcessRequestResponse(const std::string &flag, int32_t requestId) override
void OnNewProcessRequestResponse(const std::string &flag, int32_t requestId,
const std::string &callerProcessName) override
{}
void OnNewProcessRequestTimeoutResponse(int32_t requestId) override
{}
@@ -87,7 +87,8 @@ public:
{}
void OnTimeoutResponse(int32_t requestId) override
{}
void OnNewProcessRequestResponse(const std::string &flag, int32_t requestId) override
void OnNewProcessRequestResponse(const std::string &flag, int32_t requestId,
const std::string &callerProcessName) override
{}
void OnNewProcessRequestTimeoutResponse(int32_t requestId) override
{}