diff --git a/services/appmgr/include/app_running_manager.h b/services/appmgr/include/app_running_manager.h index 7cdf797445018372e8745b7e6da3e9d41d77654f..7a84228083bde17eebca10cb37e205fd56a0247c 100644 --- a/services/appmgr/include/app_running_manager.h +++ b/services/appmgr/include/app_running_manager.h @@ -437,9 +437,8 @@ public: int32_t RemoveUIExtensionBindItemById(int32_t uiExtensionBindAbilityId); std::shared_ptr GetAppRunningRecordByChildRecordPid(const pid_t pid); - std::shared_ptr GetMasterProcess(const std::string &bundleName, int32_t uid, - const std::string &instanceKey); - + std::shared_ptr GetSpecifiedProcess(int32_t uid, const std::string &instanceKey); + int32_t AssignRunningProcessInfoByAppRecord( std::shared_ptr appRecord, AppExecFwk::RunningProcessInfo &info) const; diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index 2237ab563b9dfb3a3e33719e4644f90fdc9af2bc..127212a5b126361a9b323228767313de003feb45 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -10184,7 +10184,7 @@ bool AppMgrServiceInner::IsSpecifiedModuleLoaded(const AAFwk::Want &want, const (void)AbilityRuntime::StartupUtil::GetAppIndex(want, appIndex); auto instanceKey = want.GetStringParam(Want::APP_INSTANCE_KEY); if (isSpecifiedProcess) { - auto appRecord = appRunningManager_->GetMasterProcess(abilityInfo.bundleName, abilityInfo.uid, instanceKey); + auto appRecord = appRunningManager_->GetSpecifiedProcess(abilityInfo.uid, instanceKey); if (appRecord != nullptr) { isDebug = appRecord->IsDebug(); return true; diff --git a/services/appmgr/src/app_running_manager.cpp b/services/appmgr/src/app_running_manager.cpp index bd4edf24ebbd9149f7fb28c2fbad1955a4bc91e0..28a295477b373d63b11c367bcf6f4188cd0c69e3 100644 --- a/services/appmgr/src/app_running_manager.cpp +++ b/services/appmgr/src/app_running_manager.cpp @@ -1864,13 +1864,12 @@ std::shared_ptr AppRunningManager::GetAppRunningRecordByChildR return nullptr; } -std::shared_ptr AppRunningManager::GetMasterProcess( - const std::string &bundleName, int32_t uid, const std::string &instanceKey) +std::shared_ptr AppRunningManager::GetSpecifiedProcess(int32_t uid, const std::string &instanceKey) { std::lock_guard guard(runningRecordMapMutex_); for (const auto &[key, appRecord]: appRunningRecordMap_) { - if (appRecord && appRecord->GetBundleName() == bundleName && appRecord->IsMasterProcess() && - appRecord->GetUid() == uid && appRecord->GetInstanceKey() == instanceKey) { + if (appRecord && appRecord->GetProcessType() == ProcessType::NORMAL && appRecord->GetUid() == uid && + appRecord->GetInstanceKey() == instanceKey) { return appRecord; } } diff --git a/test/unittest/app_mgr_service_inner_eighth_test/mock/src/mock_app_running_manager.cpp b/test/unittest/app_mgr_service_inner_eighth_test/mock/src/mock_app_running_manager.cpp index 136340c96d75c96e07899c2efb51c16f22facc34..2074dd9087b470673c7451ea3fab6fadea993b75 100644 --- a/test/unittest/app_mgr_service_inner_eighth_test/mock/src/mock_app_running_manager.cpp +++ b/test/unittest/app_mgr_service_inner_eighth_test/mock/src/mock_app_running_manager.cpp @@ -479,8 +479,7 @@ void AppRunningManager::UpdateInstanceKeyBySpecifiedId(int32_t specifiedId, std: { } -std::shared_ptr AppRunningManager::GetMasterProcess( - const std::string &bundleName, int32_t uid, const std::string &instanceKey) +std::shared_ptr AppRunningManager::GetSpecifiedProcess(int32_t uid, const std::string &instanceKey) { return AAFwk::MyStatus::GetInstance().getAppRunningRecordByPid_; } diff --git a/test/unittest/app_mgr_service_inner_ninth_test/mock/src/mock_app_running_manager.cpp b/test/unittest/app_mgr_service_inner_ninth_test/mock/src/mock_app_running_manager.cpp index 13493f04e761380d9aa271cee72daca9a0097afc..a1fcb3e6471f77471b6ff4c8521a69e154c88a6e 100644 --- a/test/unittest/app_mgr_service_inner_ninth_test/mock/src/mock_app_running_manager.cpp +++ b/test/unittest/app_mgr_service_inner_ninth_test/mock/src/mock_app_running_manager.cpp @@ -550,8 +550,7 @@ bool AppRunningManager::CheckMasterProcessAppRunningRecordIsExist( return false; } -std::shared_ptr AppRunningManager::GetMasterProcess( - const std::string &bundleName, int32_t uid, const std::string &instanceKey) +std::shared_ptr AppRunningManager::GetSpecifiedProcess(int32_t uid, const std::string &instanceKey) { return nullptr; } diff --git a/test/unittest/app_running_manager_second_test/app_running_manager_second_test.cpp b/test/unittest/app_running_manager_second_test/app_running_manager_second_test.cpp index 33f4b1cd43e5d9f8cf6ec828abafea4d9fda8f93..d02f279d0c8fcbcfba3195e6198047f20ef02e64 100644 --- a/test/unittest/app_running_manager_second_test/app_running_manager_second_test.cpp +++ b/test/unittest/app_running_manager_second_test/app_running_manager_second_test.cpp @@ -1784,7 +1784,7 @@ HWTEST_F(AppRunningManagerSecondTest, AppRunningManager_NeedNotifyAppStateChange /** * @tc.name: AppRunningManager_GetMasterProcess_0100 - * @tc.desc: Test GetMasterProcess + * @tc.desc: Test GetSpecifiedProcess * @tc.type: FUNC */ HWTEST_F(AppRunningManagerSecondTest, AppRunningManager_GetMasterProcess_0100, @@ -1792,33 +1792,29 @@ HWTEST_F(AppRunningManagerSecondTest, AppRunningManager_GetMasterProcess_0100, { TAG_LOGI(AAFwkTag::TEST, "AppRunningManager_GetMasterProcess_0100 start"); auto appRunningManager = std::make_shared(); - std::string bundleName = BUNDLE_NAME; int32_t uid = 1; std::string instanceKey = "testInstanceKey"; - auto result = appRunningManager->GetMasterProcess(bundleName, uid, instanceKey); + auto result = appRunningManager->GetSpecifiedProcess(uid, instanceKey); EXPECT_EQ(result, nullptr); auto currentRecord = std::make_shared(appInfo_, 1, PROCESS_NAME); currentRecord->mainBundleName_.clear(); appRunningManager->appRunningRecordMap_.emplace(0, nullptr); appRunningManager->appRunningRecordMap_.emplace(1, currentRecord); - result = appRunningManager->GetMasterProcess(bundleName, uid, instanceKey); + result = appRunningManager->GetSpecifiedProcess(uid, instanceKey); EXPECT_EQ(result, nullptr); - currentRecord->mainBundleName_ = bundleName; - result = appRunningManager->GetMasterProcess(bundleName, uid, instanceKey); - EXPECT_EQ(result, nullptr); - - currentRecord->isMasterProcess_ = true; - result = appRunningManager->GetMasterProcess(bundleName, uid, instanceKey); + currentRecord->processType_ = ProcessType::EXTENSION; + result = appRunningManager->GetSpecifiedProcess(uid, instanceKey); EXPECT_EQ(result, nullptr); currentRecord->mainUid_ = uid; - result = appRunningManager->GetMasterProcess(bundleName, uid, instanceKey); + result = appRunningManager->GetSpecifiedProcess(uid, instanceKey); EXPECT_EQ(result, nullptr); + currentRecord->processType_ = ProcessType::NORMAL; currentRecord->instanceKey_ = instanceKey; - result = appRunningManager->GetMasterProcess(bundleName, uid, instanceKey); + result = appRunningManager->GetSpecifiedProcess(uid, instanceKey); EXPECT_NE(result, nullptr); TAG_LOGI(AAFwkTag::TEST, "AppRunningManager_GetMasterProcess_0100 end");