fix StartSelfUIAbilityInCurrentProcess

Co-Authored-By: ya
Signed-off-by: zzl12383 <zhengzhuolan@huawei-partners.com>
This commit is contained in:
zzl12383
2026-06-18 10:35:22 +08:00
parent c60aef61e4
commit bb56566444
3 changed files with 9 additions and 5 deletions
@@ -2433,7 +2433,8 @@ int AbilityManagerService::StartAbilityForOptionInner(const Want &want, const St
!startOptions.processOptions->isRestartKeepAlive &&
!ProcessOptions::IsAttachToStatusBarItemMode(startOptions.processOptions->processMode) &&
currentProcessName != START_SELF_UI_ABILITY_IN_CHILD_PROCESS_FLAG &&
!startOptions.processOptions->isStartFromNDK) {
!startOptions.processOptions->isStartFromNDK &&
startOptions.processOptions->selfPid == -1) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "processMode is not attach to status bar item.");
AbilityEventUtil::SendStartAbilityErrorEvent(eventInfo, ERR_ABILITY_ALREADY_RUNNING,
"processMode is not attach to status bar item");
@@ -4846,6 +4846,9 @@ ErrCode UIAbilityLifecycleManager::IsUIAbilityAlreadyExist(const Want &want,
const std::string &specifiedFlag, int32_t appIndex,
const std::string &instanceKey, AppExecFwk::LaunchMode launchMode)
{
if (launchMode == AppExecFwk::LaunchMode::STANDARD) {
return ERR_OK;
}
std::unordered_map<int32_t, UIAbilityRecordPtr> tempSessionAbilityMap;
{
std::lock_guard<ffrt::mutex> guard(sessionLock_);
@@ -7391,7 +7391,7 @@ HWTEST_F(UIAbilityLifecycleManagerTest, EnableListForSCBRecovery_001, TestSize.L
/**
* @tc.name: IsUIAbilityAlreadyExist_0001
* @tc.desc: In STANDARD launch mode if a record with same ability exists return ERROR_UIABILITY_IS_ALREADY_EXIST
* @tc.desc: In SINGLETON launch mode if a record with same ability exists return ERROR_UIABILITY_IS_ALREADY_EXIST
* @tc.type: FUNC
*/
HWTEST_F(UIAbilityLifecycleManagerTest, IsUIAbilityAlreadyExist_0001, TestSize.Level1)
@@ -7408,7 +7408,7 @@ HWTEST_F(UIAbilityLifecycleManagerTest, IsUIAbilityAlreadyExist_0001, TestSize.L
abilityRequest.abilityInfo.name = abilityName;
abilityRequest.abilityInfo.bundleName = bundleName;
abilityRequest.abilityInfo.moduleName = moduleName;
abilityRequest.abilityInfo.launchMode = AppExecFwk::LaunchMode::STANDARD;
abilityRequest.abilityInfo.launchMode = AppExecFwk::LaunchMode::SINGLETON;
abilityRequest.sessionInfo = new SessionInfo();
abilityRequest.sessionInfo->instanceKey = instanceKey;
auto record = UIAbilityRecord::CreateAbilityRecord(abilityRequest);
@@ -7418,7 +7418,7 @@ HWTEST_F(UIAbilityLifecycleManagerTest, IsUIAbilityAlreadyExist_0001, TestSize.L
Want want;
want.SetElementName("device", bundleName, abilityName, moduleName);
auto ret = mgr->IsUIAbilityAlreadyExist(want, "", appIndex, instanceKey, AppExecFwk::LaunchMode::STANDARD);
auto ret = mgr->IsUIAbilityAlreadyExist(want, "", appIndex, instanceKey, AppExecFwk::LaunchMode::SINGLETON);
EXPECT_EQ(ret, ERROR_UIABILITY_IS_ALREADY_EXIST);
}
@@ -7481,7 +7481,7 @@ HWTEST_F(UIAbilityLifecycleManagerTest, IsUIAbilityAlreadyExist_0003, TestSize.L
record->SetAppIndex(0);
record->SetInstanceKey("key");
mgr->sessionAbilityMap_[5] = record;
ret = mgr->IsUIAbilityAlreadyExist(want, "flag", 0, "key", AppExecFwk::LaunchMode::STANDARD);
ret = mgr->IsUIAbilityAlreadyExist(want, "flag", 0, "key", AppExecFwk::LaunchMode::SINGLETON);
EXPECT_EQ(ret, ERR_OK);
}