diff --git a/interfaces/inner_api/ability_manager/include/ability_manager_client.h b/interfaces/inner_api/ability_manager/include/ability_manager_client.h index 8a35f3ef3e..c7b40f38c0 100644 --- a/interfaces/inner_api/ability_manager/include/ability_manager_client.h +++ b/interfaces/inner_api/ability_manager/include/ability_manager_client.h @@ -1856,14 +1856,14 @@ public: * * @param element, The uiextension ElementName. * @param moduleName, The uiextension moduleName. - * @param hostBundleName, The uiextension caller hostBundleName. + * @param hostPid, The uiextension caller pid. * @param recordNum, The returned count of uiextension. * @param userId, The User Id. * @return Returns ERR_OK on success, others on failure. */ ErrCode QueryPreLoadUIExtensionRecord(const AppExecFwk::ElementName &element, const std::string &moduleName, - const std::string &hostBundleName, + const int32_t hostPid, int32_t &recordNum, int32_t userId = DEFAULT_INVAL_VALUE); diff --git a/interfaces/inner_api/ability_manager/include/ability_manager_interface.h b/interfaces/inner_api/ability_manager/include/ability_manager_interface.h index db37c122b1..4b715a9c17 100644 --- a/interfaces/inner_api/ability_manager/include/ability_manager_interface.h +++ b/interfaces/inner_api/ability_manager/include/ability_manager_interface.h @@ -2270,7 +2270,7 @@ public: */ virtual int32_t QueryPreLoadUIExtensionRecord(const AppExecFwk::ElementName &element, const std::string &moduleName, - const std::string &hostBundleName, + const int32_t hostPid, int32_t &recordNum, int32_t userId = DEFAULT_INVAL_VALUE) { diff --git a/services/abilitymgr/include/ability_connect_manager.h b/services/abilitymgr/include/ability_connect_manager.h index 57ecaf69c5..82f0478a53 100644 --- a/services/abilitymgr/include/ability_connect_manager.h +++ b/services/abilitymgr/include/ability_connect_manager.h @@ -141,7 +141,7 @@ public: */ int QueryPreLoadUIExtensionRecordInner(const AppExecFwk::ElementName &element, const std::string &moduleName, - const std::string &hostBundleName, + const int32_t hostPid, int32_t &recordNum); /** @@ -151,7 +151,7 @@ public: * @param hostBundleName, the caller application bundle name. * @return Returns ERR_OK on success, others on failure. */ - int UnloadUIExtensionAbility(const std::shared_ptr &abilityRecord, std::string &bundleName); + int UnloadUIExtensionAbility(const std::shared_ptr &abilityRecord, pid_t &hostPid); /** * ClearPreloadUIExtensionRecord, clear preload uiextension record. diff --git a/services/abilitymgr/include/ability_manager_proxy.h b/services/abilitymgr/include/ability_manager_proxy.h index 1413d9c185..e14195bb91 100644 --- a/services/abilitymgr/include/ability_manager_proxy.h +++ b/services/abilitymgr/include/ability_manager_proxy.h @@ -1770,7 +1770,7 @@ public: */ virtual int32_t QueryPreLoadUIExtensionRecord(const AppExecFwk::ElementName &element, const std::string &moduleName, - const std::string &hostBundleName, + const int32_t hostPid, int32_t &recordNum, int32_t userId = DEFAULT_INVAL_VALUE) override; diff --git a/services/abilitymgr/include/ability_manager_service.h b/services/abilitymgr/include/ability_manager_service.h index 9a971238c3..ab4d4c8f3b 100644 --- a/services/abilitymgr/include/ability_manager_service.h +++ b/services/abilitymgr/include/ability_manager_service.h @@ -489,7 +489,7 @@ public: int PreloadUIExtensionAbility(const Want &want, std::string &hostBundleName, int32_t userId = DEFAULT_INVAL_VALUE, int32_t hostPid = DEFAULT_INVAL_VALUE) override; - int UnloadUIExtensionAbility(const std::shared_ptr &abilityRecord, std::string &bundleName); + int UnloadUIExtensionAbility(const std::shared_ptr &abilityRecord, pid_t &hostPid); /** * Change the visibility state of an UIAbility. @@ -2159,7 +2159,7 @@ public: */ virtual int32_t QueryPreLoadUIExtensionRecord(const AppExecFwk::ElementName &element, const std::string &moduleName, - const std::string &hostBundleName, + const int32_t hostPid, int32_t &recordNum, int32_t userId = DEFAULT_INVAL_VALUE) override; diff --git a/services/abilitymgr/include/extension_record/extension_record_manager.h b/services/abilitymgr/include/extension_record/extension_record_manager.h index 40de7760d7..eb6ab2d71b 100644 --- a/services/abilitymgr/include/extension_record/extension_record_manager.h +++ b/services/abilitymgr/include/extension_record/extension_record_manager.h @@ -32,7 +32,7 @@ namespace AbilityRuntime { class ExtensionRecordManager : public std::enable_shared_from_this { public: using ExtensionAbilityRecordMap = std::map>; - using PreLoadUIExtensionMapKey = std::tuple; + using PreLoadUIExtensionMapKey = std::tuple; using PreLoadUIExtensionMapType = std::map>>; explicit ExtensionRecordManager(const int32_t userId); @@ -91,17 +91,17 @@ public: int32_t hostPid = AAFwk::DEFAULT_INVAL_VALUE); bool IsPreloadExtensionRecord(const AAFwk::AbilityRequest &abilityRequest, - const std::string &hostBundleName, std::shared_ptr &extensionRecord, bool &isLoaded); + const pid_t &hostPid, std::shared_ptr &extensionRecord, bool &isLoaded); int32_t AddPreloadUIExtensionRecord(const std::shared_ptr abilityRecord); void RemoveAllPreloadUIExtensionRecord(PreLoadUIExtensionMapKey &preLoadUIExtensionInfo); bool RemovePreloadUIExtensionRecord( - const std::tuple extensionRecordMapKey); + const std::tuple extensionRecordMapKey); bool RemovePreloadUIExtensionRecordById( - const std::tuple &extensionRecordMapKey, + const std::tuple &extensionRecordMapKey, int32_t extensionRecordId); int32_t GetOrCreateExtensionRecord(const AAFwk::AbilityRequest &abilityRequest, const std::string &hostBundleName, @@ -121,7 +121,7 @@ public: void BackgroundTimeout(int32_t extensionRecordId); void TerminateTimeout(int32_t extensionRecordId); - int32_t GetHostBundleNameForExtensionId(int32_t extensionRecordId, std::string& hostBundleName); + int32_t GetHostPidForExtensionId(int32_t extensionRecordId, pid_t& hostPid); void GetCallerTokenList(const std::shared_ptr &abilityRecord, std::list> &callerList); @@ -136,7 +136,7 @@ public: */ int32_t QueryPreLoadUIExtensionRecord(const AppExecFwk::ElementName &element, const std::string &moduleName, - const std::string &hostBundleName, + const int32_t hostPid, int32_t &recordNum); private: diff --git a/services/abilitymgr/src/ability_connect_manager.cpp b/services/abilitymgr/src/ability_connect_manager.cpp index e25038f463..8588e49692 100644 --- a/services/abilitymgr/src/ability_connect_manager.cpp +++ b/services/abilitymgr/src/ability_connect_manager.cpp @@ -618,14 +618,14 @@ int AbilityConnectManager::PreloadUIExtensionAbilityInner(const AbilityRequest & } int AbilityConnectManager::UnloadUIExtensionAbility(const std::shared_ptr &abilityRecord, - std::string &hostBundleName) + pid_t &hostPid) { TAG_LOGD(AAFwkTag::ABILITYMGR, "call"); //Get preLoadUIExtensionInfo CHECK_POINTER_AND_RETURN(abilityRecord, ERR_INVALID_VALUE); auto preLoadUIExtensionInfo = std::make_tuple(abilityRecord->GetWant().GetElement().GetAbilityName(), abilityRecord->GetWant().GetElement().GetBundleName(), - abilityRecord->GetWant().GetElement().GetModuleName(), hostBundleName); + abilityRecord->GetWant().GetElement().GetModuleName(), hostPid); //delete preLoadUIExtensionMap CHECK_POINTER_AND_RETURN(uiExtensionAbilityRecordMgr_, ERR_NULL_OBJECT); auto extensionRecordId = abilityRecord->GetUIExtensionAbilityId(); @@ -2543,16 +2543,16 @@ void AbilityConnectManager::ClearPreloadUIExtensionRecord(const std::shared_ptr< TAG_LOGD(AAFwkTag::ABILITYMGR, "called"); CHECK_POINTER(abilityRecord); auto extensionRecordId = abilityRecord->GetUIExtensionAbilityId(); - std::string hostBundleName; + pid_t hostPid; CHECK_POINTER(uiExtensionAbilityRecordMgr_); - auto ret = uiExtensionAbilityRecordMgr_->GetHostBundleNameForExtensionId(extensionRecordId, hostBundleName); + auto ret = uiExtensionAbilityRecordMgr_->GetHostPidForExtensionId(extensionRecordId, hostPid); if (ret != ERR_OK) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "GetHostBundleNameForExtensionId fail"); + TAG_LOGE(AAFwkTag::ABILITYMGR, "GetHostPidForExtensionId fail"); return; } auto extensionRecordMapKey = std::make_tuple(abilityRecord->GetWant().GetElement().GetAbilityName(), abilityRecord->GetWant().GetElement().GetBundleName(), - abilityRecord->GetWant().GetElement().GetModuleName(), hostBundleName); + abilityRecord->GetWant().GetElement().GetModuleName(), hostPid); uiExtensionAbilityRecordMgr_->RemovePreloadUIExtensionRecordById(extensionRecordMapKey, extensionRecordId); } @@ -3837,12 +3837,12 @@ int32_t AbilityConnectManager::UpdateKeepAliveEnableState(const std::string &bun int32_t AbilityConnectManager::QueryPreLoadUIExtensionRecordInner(const AppExecFwk::ElementName &element, const std::string &moduleName, - const std::string &hostBundleName, + const int32_t hostPid, int32_t &recordNum) { CHECK_POINTER_AND_RETURN(uiExtensionAbilityRecordMgr_, ERR_NULL_OBJECT); return uiExtensionAbilityRecordMgr_->QueryPreLoadUIExtensionRecord( - element, moduleName, hostBundleName, recordNum); + element, moduleName, hostPid, recordNum); } std::shared_ptr AbilityConnectManager::GetUIExtensionBySessionFromServiceMap( diff --git a/services/abilitymgr/src/ability_manager_client.cpp b/services/abilitymgr/src/ability_manager_client.cpp index eccba61611..25e9c68246 100644 --- a/services/abilitymgr/src/ability_manager_client.cpp +++ b/services/abilitymgr/src/ability_manager_client.cpp @@ -2285,7 +2285,7 @@ ErrCode AbilityManagerClient::UnregisterHiddenStartObserver(const sptrQueryPreLoadUIExtensionRecord( - element, moduleName, hostBundleName, recordNum, userId); + element, moduleName, hostPid, recordNum, userId); } ErrCode AbilityManagerClient::RevokeDelegator(sptr token) diff --git a/services/abilitymgr/src/ability_manager_proxy.cpp b/services/abilitymgr/src/ability_manager_proxy.cpp index 600ce72a0d..46991f6b8e 100644 --- a/services/abilitymgr/src/ability_manager_proxy.cpp +++ b/services/abilitymgr/src/ability_manager_proxy.cpp @@ -6710,7 +6710,7 @@ int32_t AbilityManagerProxy::UnregisterHiddenStartObserver(const sptr &abilityRecord, - std::string &hostBundleName) + pid_t &hostPid) { TAG_LOGI(AAFwkTag::ABILITYMGR, "call"); CHECK_POINTER_AND_RETURN(abilityRecord, ERR_INVALID_VALUE); @@ -3702,7 +3702,7 @@ int AbilityManagerService::UnloadUIExtensionAbility(const std::shared_ptrUnloadUIExtensionAbility(abilityRecord, hostBundleName); + return connectManager->UnloadUIExtensionAbility(abilityRecord, hostPid); } int AbilityManagerService::RequestModalUIExtension(const Want &want) @@ -15258,7 +15258,7 @@ int32_t AbilityManagerService::UnregisterHiddenStartObserver(const sptrQueryPreLoadUIExtensionRecordInner( - element, moduleName, hostBundleName, recordNum); + element, moduleName, hostPid, recordNum); } int32_t AbilityManagerService::RevokeDelegator(sptr token) diff --git a/services/abilitymgr/src/ability_manager_stub.cpp b/services/abilitymgr/src/ability_manager_stub.cpp index 1c564c78f4..5c4f8a5d86 100644 --- a/services/abilitymgr/src/ability_manager_stub.cpp +++ b/services/abilitymgr/src/ability_manager_stub.cpp @@ -4792,12 +4792,12 @@ int32_t AbilityManagerStub::QueryPreLoadUIExtensionRecordInner(MessageParcel &da return ERR_INVALID_VALUE; } std::string moduleName = data.ReadString(); - std::string hostBundleName = data.ReadString(); + int32_t hostPid = data.ReadInt32(); int32_t userId = data.ReadInt32(); int32_t recordNum; int32_t result = QueryPreLoadUIExtensionRecord( - *element, moduleName, hostBundleName, recordNum, userId); + *element, moduleName, hostPid, recordNum, userId); if (!reply.WriteInt32(recordNum)) { TAG_LOGE(AAFwkTag::UI_EXT, "reply write recordNum fail"); return INNER_ERR; diff --git a/services/abilitymgr/src/extension_record/extension_record.cpp b/services/abilitymgr/src/extension_record/extension_record.cpp index 4aab5b7bc2..5f5968875b 100644 --- a/services/abilitymgr/src/extension_record/extension_record.cpp +++ b/services/abilitymgr/src/extension_record/extension_record.cpp @@ -62,7 +62,7 @@ void ExtensionRecord::UnloadUIExtensionAbility() TAG_LOGE(AAFwkTag::ABILITYMGR, "unRegisterObserver error"); } auto result = DelayedSingleton::GetInstance()->UnloadUIExtensionAbility( - abilityRecord_, hostBundleName_); + abilityRecord_, hostPid_); if (result != ERR_OK) { TAG_LOGE(AAFwkTag::ABILITYMGR, "UIExtension unload error"); } diff --git a/services/abilitymgr/src/extension_record/extension_record_manager.cpp b/services/abilitymgr/src/extension_record/extension_record_manager.cpp index a717f1fbeb..6fa79d51f2 100644 --- a/services/abilitymgr/src/extension_record/extension_record_manager.cpp +++ b/services/abilitymgr/src/extension_record/extension_record_manager.cpp @@ -162,12 +162,13 @@ int32_t ExtensionRecordManager::GetOrCreateExtensionRecord(const AAFwk::AbilityR } std::shared_ptr extensionRecord = nullptr; TAG_LOGD(AAFwkTag::ABILITYMGR, "Check Preload Extension Record."); - auto result = IsPreloadExtensionRecord(abilityRequest, hostBundleName, extensionRecord, isLoaded); + auto hostPid = IPCSkeleton::GetCallingPid(); + auto result = IsPreloadExtensionRecord(abilityRequest, hostPid, extensionRecord, isLoaded); if (result) { std::string abilityName = abilityRequest.want.GetElement().GetAbilityName(); std::string bundleName = abilityRequest.want.GetElement().GetBundleName(); std::string moduleName = abilityRequest.want.GetElement().GetModuleName(); - auto extensionRecordMapKey = std::make_tuple(abilityName, bundleName, moduleName, hostBundleName); + auto extensionRecordMapKey = std::make_tuple(abilityName, bundleName, moduleName, hostPid); RemovePreloadUIExtensionRecord(extensionRecordMapKey); } else { int32_t ret = GetOrCreateExtensionRecordInner(abilityRequest, hostBundleName, extensionRecord, isLoaded); @@ -288,7 +289,7 @@ int32_t ExtensionRecordManager::UpdateProcessName(const AAFwk::AbilityRequest &a return ERR_OK; } -int32_t ExtensionRecordManager::GetHostBundleNameForExtensionId(int32_t extensionRecordId, std::string &hostBundleName) +int32_t ExtensionRecordManager::GetHostPidForExtensionId(int32_t extensionRecordId, pid_t &hostPid) { TAG_LOGD(AAFwkTag::ABILITYMGR, "call"); std::lock_guard lock(mutex_); @@ -296,7 +297,7 @@ int32_t ExtensionRecordManager::GetHostBundleNameForExtensionId(int32_t extensio if (extensionRecords_.find(extensionRecordId) != extensionRecords_.end()) { extensionRecord = extensionRecords_[extensionRecordId]; CHECK_POINTER_AND_RETURN(extensionRecord, ERR_INVALID_VALUE); - hostBundleName = extensionRecord->hostBundleName_; + hostPid = extensionRecord->hostPid_; return ERR_OK; } return ERR_INVALID_VALUE; @@ -312,12 +313,12 @@ int32_t ExtensionRecordManager::AddPreloadUIExtensionRecord(const std::shared_pt if (extensionRecords_.find(extensionRecordId) != extensionRecords_.end()) { extensionRecord = extensionRecords_[extensionRecordId]; CHECK_POINTER_AND_RETURN(extensionRecord, ERR_INVALID_VALUE); - auto hostBundleName = extensionRecord->hostBundleName_; + auto hostPid = extensionRecord->hostPid_; auto preLoadUIExtensionInfo = std::make_tuple(abilityRecord->GetWant().GetElement().GetAbilityName(), abilityRecord->GetWant().GetElement().GetBundleName(), - abilityRecord->GetWant().GetElement().GetModuleName(), hostBundleName); - TAG_LOGD(AAFwkTag::ABILITYMGR, "hostBundleName: %{public}s, elementName:%{public}s/%{public}s", - hostBundleName.c_str(), abilityRecord->GetWant().GetElement().GetBundleName().c_str(), + abilityRecord->GetWant().GetElement().GetModuleName(), hostPid); + TAG_LOGD(AAFwkTag::ABILITYMGR, "hostPid: %{public}d, elementName:%{public}s/%{public}s", + hostPid, abilityRecord->GetWant().GetElement().GetBundleName().c_str(), abilityRecord->GetWant().GetElement().GetAbilityName().c_str()); std::lock_guard lock(preloadUIExtensionMapMutex_); preloadUIExtensionMap_[preLoadUIExtensionInfo].push_back(extensionRecord); @@ -339,15 +340,15 @@ void ExtensionRecordManager::RemoveAllPreloadUIExtensionRecord(PreLoadUIExtensio } bool ExtensionRecordManager::IsPreloadExtensionRecord(const AAFwk::AbilityRequest &abilityRequest, - const std::string &hostBundleName, std::shared_ptr &extensionRecord, bool &isLoaded) + const pid_t &hostPid, std::shared_ptr &extensionRecord, bool &isLoaded) { TAG_LOGD(AAFwkTag::ABILITYMGR, "call."); std::string abilityName = abilityRequest.want.GetElement().GetAbilityName(); std::string bundleName = abilityRequest.want.GetElement().GetBundleName(); std::string moduleName = abilityRequest.want.GetElement().GetModuleName(); - auto extensionRecordMapKey = std::make_tuple(abilityName, bundleName, moduleName, hostBundleName); - TAG_LOGD(AAFwkTag::ABILITYMGR, "hostBundleName: %{public}s, bundleName: %{public}s", - hostBundleName.c_str(), bundleName.c_str()); + auto extensionRecordMapKey = std::make_tuple(abilityName, bundleName, moduleName, hostPid); + TAG_LOGD(AAFwkTag::ABILITYMGR, "hostBundleName: %{public}d, bundleName: %{public}s", + hostPid, bundleName.c_str()); std::lock_guard lock(preloadUIExtensionMapMutex_); auto item = preloadUIExtensionMap_.find(extensionRecordMapKey); if (item != preloadUIExtensionMap_.end()) { @@ -369,7 +370,7 @@ bool ExtensionRecordManager::IsPreloadExtensionRecord(const AAFwk::AbilityReques } bool ExtensionRecordManager::RemovePreloadUIExtensionRecordById( - const std::tuple &extensionRecordMapKey, + const std::tuple &extensionRecordMapKey, int32_t extensionRecordId) { TAG_LOGD(AAFwkTag::ABILITYMGR, "call."); @@ -400,7 +401,7 @@ bool ExtensionRecordManager::RemovePreloadUIExtensionRecordById( } bool ExtensionRecordManager::RemovePreloadUIExtensionRecord( - const std::tuple extensionRecordMapKey) + const std::tuple extensionRecordMapKey) { TAG_LOGD(AAFwkTag::ABILITYMGR, "call."); std::lock_guard lock(preloadUIExtensionMapMutex_); @@ -810,23 +811,22 @@ bool ExtensionRecordManager::IsFocused( int32_t ExtensionRecordManager::QueryPreLoadUIExtensionRecord(const AppExecFwk::ElementName &element, const std::string &moduleName, - const std::string &hostBundleName, + const int32_t hostPid, int32_t &recordNum) { std::string abilityName = element.GetAbilityName(); std::string bundleName = element.GetBundleName(); TAG_LOGD(AAFwkTag::UI_EXT, - "hostBundleName: %{public}s, bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s", - hostBundleName.c_str(), bundleName.c_str(), moduleName.c_str(), abilityName.c_str()); - if (element.GetAbilityName().empty() || element.GetBundleName().empty() || moduleName.empty() || - hostBundleName.empty()) { + "hostPid: %{public}d, bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s", + hostPid, bundleName.c_str(), moduleName.c_str(), abilityName.c_str()); + if (element.GetAbilityName().empty() || element.GetBundleName().empty() || moduleName.empty()) { recordNum = 0; - TAG_LOGD(AAFwkTag::UI_EXT, "element or hostBundleName is null."); + TAG_LOGD(AAFwkTag::UI_EXT, "element is null."); return ERR_INVALID_VALUE; } auto extensionRecordMapKey = - std::make_tuple(abilityName, bundleName, moduleName, hostBundleName); + std::make_tuple(abilityName, bundleName, moduleName, hostPid); std::lock_guard lock(preloadUIExtensionMapMutex_); auto item = preloadUIExtensionMap_.find(extensionRecordMapKey); if (item != preloadUIExtensionMap_.end()) { diff --git a/test/fuzztest/extensionrecordmanager_fuzzer/extensionrecordmanager_fuzzer.cpp b/test/fuzztest/extensionrecordmanager_fuzzer/extensionrecordmanager_fuzzer.cpp index caf2fc2e4e..fabb48f5eb 100644 --- a/test/fuzztest/extensionrecordmanager_fuzzer/extensionrecordmanager_fuzzer.cpp +++ b/test/fuzztest/extensionrecordmanager_fuzzer/extensionrecordmanager_fuzzer.cpp @@ -65,7 +65,7 @@ bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) sptr focusedCallerToken; sptr token; sptr focusToken; - std::tuple extensionRecordMapKey; + std::tuple extensionRecordMapKey; FuzzedDataProvider fdp(data, size); userId = fdp.ConsumeIntegral(); @@ -95,10 +95,10 @@ bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) extensionRecordManager->GetAbilityRecordBySessionInfo(sessionInfo); extensionRecordManager->IsHostSpecifiedProcessValid(abilityRequest, record, process); extensionRecordManager->UpdateProcessName(abilityRequest, record); - extensionRecordManager->GetHostBundleNameForExtensionId(extensionRecordId, hostBundleName); + extensionRecordManager->GetHostPidForExtensionId(extensionRecordId, hostPid); extensionRecordManager->AddPreloadUIExtensionRecord(abilityRecord); extensionRecordManager->RemoveAllPreloadUIExtensionRecord(preLoadUIExtensionInfo); - extensionRecordManager->IsPreloadExtensionRecord(abilityRequest, hostBundleName, extensionRecord, isLoaded); + extensionRecordManager->IsPreloadExtensionRecord(abilityRequest, hostPid, extensionRecord, isLoaded); extensionRecordManager->RemovePreloadUIExtensionRecordById(extensionRecordMapKey, extensionRecordId); extensionRecordManager->RemovePreloadUIExtensionRecord(extensionRecordMapKey); extensionRecordManager->GetOrCreateExtensionRecordInner(abilityRequest, hostBundleName, extensionRecord, isLoaded); @@ -117,7 +117,7 @@ bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) extensionRecordManager->TerminateTimeout(extensionRecordId); extensionRecordManager->GetCallerTokenList(abilityRecord, callerList); extensionRecordManager->IsFocused(extensionRecordId, token, focusToken); - extensionRecordManager->QueryPreLoadUIExtensionRecord(element, moduleName, hostBundleName, recordNum); + extensionRecordManager->QueryPreLoadUIExtensionRecord(element, moduleName, hostPid, recordNum); return true; } } // namespace OHOS diff --git a/test/fuzztest/extensionrecordmanagera_fuzzer/extensionrecordmanagera_fuzzer.cpp b/test/fuzztest/extensionrecordmanagera_fuzzer/extensionrecordmanagera_fuzzer.cpp index 3f3ba33cf8..13b27c9875 100755 --- a/test/fuzztest/extensionrecordmanagera_fuzzer/extensionrecordmanagera_fuzzer.cpp +++ b/test/fuzztest/extensionrecordmanagera_fuzzer/extensionrecordmanagera_fuzzer.cpp @@ -122,18 +122,18 @@ void FuzztestExtensionRecordManagerFunc2(std::shared_ptr mgr->UpdateProcessName(abilityRequest, record); record->processMode_ = PROCESS_MODE_HOST_SPECIFIED; mgr->UpdateProcessName(abilityRequest, record); - std::string bundleName = "bundleName"; - mgr->GetHostBundleNameForExtensionId(1, bundleName); // 1 means id + int32_t hostPid = 0; + mgr->GetHostPidForExtensionId(1, hostPid); // 1 means id mgr->AddExtensionRecord(1, record); // 1 means id - mgr->GetHostBundleNameForExtensionId(1, bundleName); // 1 means id, exist. - mgr->GetHostBundleNameForExtensionId(int32Param, bundleName); // 1 means id, exist. + mgr->GetHostPidForExtensionId(1, hostPid); // 1 means id, exist. + mgr->GetHostPidForExtensionId(int32Param, hostPid); // 1 means id, exist. abilityRecord->SetUIExtensionAbilityId(-1); mgr->AddExtensionRecord(1, record); // 1 means id abilityRecord->SetUIExtensionAbilityId(1); mgr->AddPreloadUIExtensionRecord(abilityRecord); ExtensionRecordManager::PreLoadUIExtensionMapKey key; mgr->RemoveAllPreloadUIExtensionRecord(key); // called - mgr->IsPreloadExtensionRecord(abilityRequest, stringParam, record, boolParam); // called + mgr->IsPreloadExtensionRecord(abilityRequest, hostPid, record, boolParam); // called mgr->RemovePreloadUIExtensionRecordById(key, int32Param); // called mgr->RemovePreloadUIExtensionRecord(key); // called mgr->GetOrCreateExtensionRecordInner(abilityRequest, stringParam, record, boolParam); // called diff --git a/test/moduletest/ability_manager_client_test/ability_manager_client_test.cpp b/test/moduletest/ability_manager_client_test/ability_manager_client_test.cpp index fb2e74a83b..0e2d8a7039 100644 --- a/test/moduletest/ability_manager_client_test/ability_manager_client_test.cpp +++ b/test/moduletest/ability_manager_client_test/ability_manager_client_test.cpp @@ -545,11 +545,11 @@ HWTEST_F(AbilityManagerClientTest, QueryPreLoadUIExtensionRecord_0100, TestSize. { OHOS::AppExecFwk::ElementName elementName; std::string moduleName {}; - std::string hostBundleName {}; + int32_t hostPid = 1; int32_t recordNum = 1; int32_t userId = 1; auto result = AbilityManagerClient::GetInstance()->QueryPreLoadUIExtensionRecord(elementName, - moduleName, hostBundleName, recordNum, userId); + moduleName, hostPid, recordNum, userId); EXPECT_EQ(result, ERR_OK); } diff --git a/test/unittest/ability_connect_manager_first_test/ability_connect_manager_first_test.cpp b/test/unittest/ability_connect_manager_first_test/ability_connect_manager_first_test.cpp index a1c0408cba..8debb664a2 100644 --- a/test/unittest/ability_connect_manager_first_test/ability_connect_manager_first_test.cpp +++ b/test/unittest/ability_connect_manager_first_test/ability_connect_manager_first_test.cpp @@ -885,9 +885,9 @@ HWTEST_F(AbilityConnectManagerTest, UnloadUIExtensionAbility_001, TestSize.Level abilityRecord->abilityInfo_.type = AbilityType::PAGE; abilityRecord->SetAbilityState(AbilityState::INACTIVE); abilityRecord->connRecordList_.push_back(connection); - std::string hostBundName = "bundleName"; + int32_t hostPid = 10; - int result = connectManager->UnloadUIExtensionAbility(abilityRecord, hostBundName); + int result = connectManager->UnloadUIExtensionAbility(abilityRecord, hostPid); EXPECT_NE(result, ERR_OK); TAG_LOGI(AAFwkTag::TEST, "UnloadUIExtensionAbility_001 end"); } diff --git a/test/unittest/ability_connect_manager_fourth_test/ability_connect_manager_fourth_test.cpp b/test/unittest/ability_connect_manager_fourth_test/ability_connect_manager_fourth_test.cpp index 5688697591..1bf083c072 100644 --- a/test/unittest/ability_connect_manager_fourth_test/ability_connect_manager_fourth_test.cpp +++ b/test/unittest/ability_connect_manager_fourth_test/ability_connect_manager_fourth_test.cpp @@ -943,16 +943,16 @@ HWTEST_F(AbilityConnectManagerFourthTest, QueryPreLoadUIExtensionRecordInner_001 AppExecFwk::ElementName element("deviceId", "bundleName", "abilityName", "moduleName"); std::string moduleName = "testModule"; - std::string hostBundleName = "testHostBundle"; + int32_t hostPid = 0; int32_t recordNum = 0; int32_t result = - connectManager->QueryPreLoadUIExtensionRecordInner(element, moduleName, hostBundleName, recordNum); + connectManager->QueryPreLoadUIExtensionRecordInner(element, moduleName, hostPid, recordNum); EXPECT_EQ(result, ERR_OK); connectManager->uiExtensionAbilityRecordMgr_ = nullptr; result = - connectManager->QueryPreLoadUIExtensionRecordInner(element, moduleName, hostBundleName, recordNum); + connectManager->QueryPreLoadUIExtensionRecordInner(element, moduleName, hostPid, recordNum); EXPECT_EQ(result, ERR_NULL_OBJECT); TAG_LOGI(AAFwkTag::TEST, "QueryPreLoadUIExtensionRecordInner_001 end"); } @@ -969,11 +969,11 @@ HWTEST_F(AbilityConnectManagerFourthTest, QueryPreLoadUIExtensionRecordInner_002 AppExecFwk::ElementName element("deviceId", "bundleName", "abilityName", "moduleName"); std::string moduleName = "testModule"; - std::string hostBundleName = "testHostBundle"; + int32_t hostPid = 0; int32_t recordNum = 0; connectManager->uiExtensionAbilityRecordMgr_ = nullptr; - int result = connectManager->QueryPreLoadUIExtensionRecordInner(element, moduleName, hostBundleName, recordNum); + int result = connectManager->QueryPreLoadUIExtensionRecordInner(element, moduleName, hostPid, recordNum); EXPECT_EQ(result, ERR_NULL_OBJECT); TAG_LOGI(AAFwkTag::TEST, "QueryPreLoadUIExtensionRecordInner_002 end"); } diff --git a/test/unittest/ability_connect_manager_test/ability_connect_manager_test.cpp b/test/unittest/ability_connect_manager_test/ability_connect_manager_test.cpp index a73cfc87f0..c63fbdeacc 100644 --- a/test/unittest/ability_connect_manager_test/ability_connect_manager_test.cpp +++ b/test/unittest/ability_connect_manager_test/ability_connect_manager_test.cpp @@ -3457,8 +3457,8 @@ HWTEST_F(AbilityConnectManagerTest, UnloadUIExtensionAbility_0100, TestSize.Leve AppExecFwk::ElementName providerElement("0", "com.ohos.uiextensionprovider", "UIExtensionProvider", "entry"); abilityRequest.want.SetElement(providerElement); std::shared_ptr abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); - std::string hostBundleName = "com.ohos.uiextensionuser"; - auto ret = connectManager->UnloadUIExtensionAbility(abilityRecord, hostBundleName); + int32_t hostPid = 0; + auto ret = connectManager->UnloadUIExtensionAbility(abilityRecord, hostPid); EXPECT_EQ(ret, ERR_CONNECT_MANAGER_NULL_ABILITY_RECORD); } diff --git a/test/unittest/ability_manager_proxy_sixth_test/ability_manager_proxy_sixth_test.cpp b/test/unittest/ability_manager_proxy_sixth_test/ability_manager_proxy_sixth_test.cpp index 6465a49151..8369e59d39 100644 --- a/test/unittest/ability_manager_proxy_sixth_test/ability_manager_proxy_sixth_test.cpp +++ b/test/unittest/ability_manager_proxy_sixth_test/ability_manager_proxy_sixth_test.cpp @@ -690,19 +690,19 @@ HWTEST_F(AbilityManagerProxySixthTest, AbilityManagerProxy_QueryPreLoadUIExtensi { AppExecFwk::ElementName element; std::string moduleName; - std::string hostBundleName; + int32_t hostPid = 0; int32_t recordNum = 0; int32_t userId = 100; EXPECT_CALL(*mock_, SendRequest(_, _, _, _)) .Times(1) .WillOnce(Return(-1)); - auto res = proxy_->QueryPreLoadUIExtensionRecord(element, moduleName, hostBundleName, recordNum, userId); + auto res = proxy_->QueryPreLoadUIExtensionRecord(element, moduleName, hostPid, recordNum, userId); EXPECT_EQ(res, -1); EXPECT_CALL(*mock_, SendRequest(_, _, _, _)) .Times(1) .WillOnce(Invoke(mock_.GetRefPtr(), &AbilityManagerStubMock::InvokeSendRequest)); - res = proxy_->QueryPreLoadUIExtensionRecord(element, moduleName, hostBundleName, recordNum, userId); + res = proxy_->QueryPreLoadUIExtensionRecord(element, moduleName, hostPid, recordNum, userId); EXPECT_EQ(static_cast(AbilityManagerInterfaceCode::QUERY_PRELOAD_UIEXTENSION_RECORD), mock_->code_); EXPECT_EQ(res, NO_ERROR); } diff --git a/test/unittest/ability_manager_service_third_test/ability_manager_service_third_test.cpp b/test/unittest/ability_manager_service_third_test/ability_manager_service_third_test.cpp index a72328eb02..ebb03659f2 100644 --- a/test/unittest/ability_manager_service_third_test/ability_manager_service_third_test.cpp +++ b/test/unittest/ability_manager_service_third_test/ability_manager_service_third_test.cpp @@ -1097,8 +1097,8 @@ HWTEST_F(AbilityManagerServiceThirdTest, UnloadUIExtensionAbility_001, TestSize. abilityRequest.want.SetElement(providerElement); abilityRequest.abilityInfo.type = AbilityType::EXTENSION; std::shared_ptr abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); - std::string hostBundleName = "com.ohos.uiextensionuser"; - auto result = abilityMs->UnloadUIExtensionAbility(abilityRecord, hostBundleName); + int32_t hostPid = 0; + auto result = abilityMs->UnloadUIExtensionAbility(abilityRecord, hostPid); EXPECT_EQ(result, ERR_INVALID_VALUE); TAG_LOGI(AAFwkTag::TEST, "finish."); } diff --git a/test/unittest/ability_manager_service_thirteenth_test/mock/src/mock_ability_connect_manager.cpp b/test/unittest/ability_manager_service_thirteenth_test/mock/src/mock_ability_connect_manager.cpp index cd0fcfd419..33abd8eff5 100644 --- a/test/unittest/ability_manager_service_thirteenth_test/mock/src/mock_ability_connect_manager.cpp +++ b/test/unittest/ability_manager_service_thirteenth_test/mock/src/mock_ability_connect_manager.cpp @@ -132,7 +132,7 @@ int AbilityConnectManager::PreloadUIExtensionAbilityInner(const AbilityRequest & } int AbilityConnectManager::UnloadUIExtensionAbility(const std::shared_ptr &abilityRecord, - std::string &hostBundleName) + int32_t &hostPid) { return ERR_OK; } @@ -769,7 +769,7 @@ int32_t AbilityConnectManager::UpdateKeepAliveEnableState(const std::string &bun int32_t AbilityConnectManager::QueryPreLoadUIExtensionRecordInner(const AppExecFwk::ElementName &element, const std::string &moduleName, - const std::string &hostBundleName, + const int32_t hostPid, int32_t &recordNum) { return ERR_OK; diff --git a/test/unittest/frameworks_kits_ability_ability_runtime_test/mock_ability_manager_client.cpp b/test/unittest/frameworks_kits_ability_ability_runtime_test/mock_ability_manager_client.cpp index a45e161b77..dc6dd009ce 100644 --- a/test/unittest/frameworks_kits_ability_ability_runtime_test/mock_ability_manager_client.cpp +++ b/test/unittest/frameworks_kits_ability_ability_runtime_test/mock_ability_manager_client.cpp @@ -1080,7 +1080,7 @@ ErrCode AbilityManagerClient::UnregisterHiddenStartObserver(const sptr(0); - std::tuple extensionRecordMapKey; + std::tuple extensionRecordMapKey; int32_t extensionRecordId = 0; EXPECT_FALSE(extRecordMgr->RemovePreloadUIExtensionRecordById(extensionRecordMapKey, extensionRecordId)); @@ -257,9 +257,9 @@ HWTEST_F(ExtensionRecordManagerSecondTest, GetHostBundleNameForExtensionId_0100, { auto extRecordMgr = std::make_shared(0); extRecordMgr->extensionRecords_.clear(); - std::string hostBundleName = ""; + int32_t hostPid = 0; - auto ret = extRecordMgr->GetHostBundleNameForExtensionId(1, hostBundleName); + auto ret = extRecordMgr->GetHostPidForExtensionId(1, hostPid); EXPECT_EQ(ret, ERR_INVALID_VALUE); } @@ -273,7 +273,7 @@ HWTEST_F(ExtensionRecordManagerSecondTest, GetHostBundleNameForExtensionId_0100, HWTEST_F(ExtensionRecordManagerSecondTest, RemoveAllPreloadUIExtensionRecord_0100, TestSize.Level1) { auto extRecordMgr = std::make_shared(0); - ExtensionRecordManager::PreLoadUIExtensionMapKey preLoadUIExtensionInfo("1", "2", "3", "4"); + ExtensionRecordManager::PreLoadUIExtensionMapKey preLoadUIExtensionInfo("1", "2", "3", 4); extRecordMgr->preloadUIExtensionMap_ = { {preLoadUIExtensionInfo, {}} }; @@ -292,8 +292,8 @@ HWTEST_F(ExtensionRecordManagerSecondTest, RemoveAllPreloadUIExtensionRecord_010 HWTEST_F(ExtensionRecordManagerSecondTest, RemoveAllPreloadUIExtensionRecord_0200, TestSize.Level1) { auto extRecordMgr = std::make_shared(0); - ExtensionRecordManager::PreLoadUIExtensionMapKey preLoadUIExtensionInfo1("1", "2", "3", "4"); - ExtensionRecordManager::PreLoadUIExtensionMapKey preLoadUIExtensionInfo2("5", "6", "7", "8"); + ExtensionRecordManager::PreLoadUIExtensionMapKey preLoadUIExtensionInfo1("1", "2", "3", 4); + ExtensionRecordManager::PreLoadUIExtensionMapKey preLoadUIExtensionInfo2("5", "6", "7", 8); extRecordMgr->preloadUIExtensionMap_ = { {preLoadUIExtensionInfo1, {}} }; @@ -312,12 +312,12 @@ HWTEST_F(ExtensionRecordManagerSecondTest, RemoveAllPreloadUIExtensionRecord_020 HWTEST_F(ExtensionRecordManagerSecondTest, RemovePreloadUIExtensionRecordById_0300, TestSize.Level1) { auto extRecordMgr = std::make_shared(0); - std::tuple extensionRecordMapKey = { - "1", "2", "3", "4" + std::tuple extensionRecordMapKey = { + "1", "2", "3", 4 }; int32_t extensionRecordId = 1; - ExtensionRecordManager::PreLoadUIExtensionMapKey preLoadUIExtensionInfo1("1", "2", "3", "4"); - ExtensionRecordManager::PreLoadUIExtensionMapKey preLoadUIExtensionInfo2("5", "6", "7", "8"); + ExtensionRecordManager::PreLoadUIExtensionMapKey preLoadUIExtensionInfo1("1", "2", "3", 4); + ExtensionRecordManager::PreLoadUIExtensionMapKey preLoadUIExtensionInfo2("5", "6", "7", 8); AAFwk::AbilityRequest abilityRequest; abilityRequest.appInfo.bundleName = "com.example.unittest"; abilityRequest.abilityInfo.name = "MainAbility"; @@ -349,13 +349,13 @@ HWTEST_F(ExtensionRecordManagerSecondTest, RemovePreloadUIExtensionRecordById_03 HWTEST_F(ExtensionRecordManagerSecondTest, RemovePreloadUIExtensionRecordById_0400, TestSize.Level1) { auto extRecordMgr = std::make_shared(0); - std::tuple extensionRecordMapKey = { - "1", "2", "3", "4" + std::tuple extensionRecordMapKey = { + "1", "2", "3", 4 }; int32_t extensionRecordId = 1; int32_t extensionRecordId2 = 2; - ExtensionRecordManager::PreLoadUIExtensionMapKey preLoadUIExtensionInfo1("1", "2", "3", "4"); - ExtensionRecordManager::PreLoadUIExtensionMapKey preLoadUIExtensionInfo2("5", "6", "7", "8"); + ExtensionRecordManager::PreLoadUIExtensionMapKey preLoadUIExtensionInfo1("1", "2", "3", 4); + ExtensionRecordManager::PreLoadUIExtensionMapKey preLoadUIExtensionInfo2("5", "6", "7", 8); AAFwk::AbilityRequest abilityRequest; abilityRequest.appInfo.bundleName = "com.example.unittest"; abilityRequest.abilityInfo.name = "MainAbility"; @@ -389,14 +389,14 @@ HWTEST_F(ExtensionRecordManagerSecondTest, RemovePreloadUIExtensionRecordById_05 { auto extRecordMgr = std::make_shared(0); - std::tuple extensionRecordMapKey = { - "1", "2", "3", "4" + std::tuple extensionRecordMapKey = { + "1", "2", "3", 4 }; int32_t extensionRecordId = 1; int32_t extensionRecordId2 = 2; int32_t extensionRecordId3 = 3; - ExtensionRecordManager::PreLoadUIExtensionMapKey preLoadUIExtensionInfo1("1", "2", "3", "4"); - ExtensionRecordManager::PreLoadUIExtensionMapKey preLoadUIExtensionInfo2("5", "6", "7", "8"); + ExtensionRecordManager::PreLoadUIExtensionMapKey preLoadUIExtensionInfo1("1", "2", "3", 4); + ExtensionRecordManager::PreLoadUIExtensionMapKey preLoadUIExtensionInfo2("5", "6", "7", 8); AAFwk::AbilityRequest abilityRequest; abilityRequest.appInfo.bundleName = "com.example.unittest"; abilityRequest.abilityInfo.name = "MainAbility"; @@ -430,8 +430,8 @@ HWTEST_F(ExtensionRecordManagerSecondTest, RemovePreloadUIExtensionRecord_0200, { auto extRecordMgr = std::make_shared(0); - std::tuple extensionRecordMapKey = { - "1", "2", "3", "4" + std::tuple extensionRecordMapKey = { + "1", "2", "3", 4 }; extRecordMgr->preloadUIExtensionMap_.clear(); @@ -595,11 +595,11 @@ HWTEST_F(ExtensionRecordManagerSecondTest, QueryPreLoadUIExtensionRecord_0100, T element.SetAbilityName(""); element.SetBundleName("HeavenlyMe"); std::string moduleName = "HeavenlyMe"; - std::string hostBundleName = "HeavenlyMe"; + int32_t hostPid = 0; int32_t recordNum = 1; auto ret = extRecordMgr->QueryPreLoadUIExtensionRecord( - element, moduleName, hostBundleName, recordNum); + element, moduleName, hostPid, recordNum); EXPECT_EQ(ret, ERR_INVALID_VALUE); } @@ -618,12 +618,12 @@ HWTEST_F(ExtensionRecordManagerSecondTest, QueryPreLoadUIExtensionRecord_0200, T element.SetAbilityName("HeavenlyMe"); element.SetBundleName("HeavenlyMe"); std::string moduleName = "HeavenlyMe"; - std::string hostBundleName = "HeavenlyMe"; + int32_t hostPid = 0; int32_t recordNum = 1; extRecordMgr->preloadUIExtensionMap_.clear(); auto ret = extRecordMgr->QueryPreLoadUIExtensionRecord( - element, moduleName, hostBundleName, recordNum); + element, moduleName, hostPid, recordNum); EXPECT_EQ(recordNum, 0); EXPECT_EQ(ret, ERR_OK); @@ -643,16 +643,16 @@ HWTEST_F(ExtensionRecordManagerSecondTest, QueryPreLoadUIExtensionRecord_0300, T element.SetAbilityName("HeavenlyMeAbility"); element.SetBundleName("HeavenlyMeBundle"); std::string moduleName = "HeavenlyMeMoudle"; - std::string hostBundleName = "HeavenlyMeHostBundle"; + int32_t hostPid = 0; int32_t recordNum = 1; ExtensionRecordManager::PreLoadUIExtensionMapKey extensionMapKey( - "HeavenlyMeAbility", "HeavenlyMeBundle", "HeavenlyMeMoudle", "HeavenlyMeHostBundle"); + "HeavenlyMeAbility", "HeavenlyMeBundle", "HeavenlyMeMoudle", hostPid); extRecordMgr->preloadUIExtensionMap_ = { {extensionMapKey, {}} }; auto ret = extRecordMgr->QueryPreLoadUIExtensionRecord( - element, moduleName, hostBundleName, recordNum); + element, moduleName, hostPid, recordNum); EXPECT_EQ(recordNum, 0); EXPECT_EQ(ret, ERR_OK); @@ -672,10 +672,10 @@ HWTEST_F(ExtensionRecordManagerSecondTest, QueryPreLoadUIExtensionRecord_0400, T element.SetAbilityName("HeavenlyMeAbility"); element.SetBundleName("HeavenlyMeBundle"); std::string moduleName = "HeavenlyMeMoudle"; - std::string hostBundleName = "HeavenlyMeHostBundle"; + int32_t hostPid = 100; int32_t recordNum = 1; ExtensionRecordManager::PreLoadUIExtensionMapKey extensionMapKey( - "HeavenlyMeAbility", "HeavenlyMeBundle", "HeavenlyMeMoudle", "HeavenlyMeHostBundle"); + "HeavenlyMeAbility", "HeavenlyMeBundle", "HeavenlyMeMoudle", hostPid); AAFwk::AbilityRequest abilityRequest; abilityRequest.appInfo.bundleName = "com.example.unittest"; abilityRequest.abilityInfo.name = "MainAbility"; @@ -688,7 +688,7 @@ HWTEST_F(ExtensionRecordManagerSecondTest, QueryPreLoadUIExtensionRecord_0400, T }; auto ret = extRecordMgr->QueryPreLoadUIExtensionRecord( - element, moduleName, hostBundleName, recordNum); + element, moduleName, hostPid, recordNum); EXPECT_EQ(recordNum, 1); EXPECT_EQ(ret, ERR_OK); @@ -764,7 +764,7 @@ HWTEST_F(ExtensionRecordManagerSecondTest, GetHostBundleNameForExtensionId_0200, { TAG_LOGI(AAFwkTag::TEST, "begin."); int32_t extensionRecordId = 0; - std::string hostBundleName = "com.example.unittest"; + int32_t hostPid = 0; std::string bundleName = "com.example.unittest"; AAFwk::AbilityRequest abilityRequest; @@ -775,11 +775,11 @@ HWTEST_F(ExtensionRecordManagerSecondTest, GetHostBundleNameForExtensionId_0200, std::shared_ptr extRecord = std::make_shared(abilityRecord); auto extRecordMgr = std::make_shared(0); - EXPECT_EQ(extRecordMgr->GetHostBundleNameForExtensionId(extensionRecordId, hostBundleName), ERR_INVALID_VALUE); + EXPECT_EQ(extRecordMgr->GetHostPidForExtensionId(extensionRecordId, hostPid), ERR_INVALID_VALUE); extRecordMgr->extensionRecords_[extensionRecordId] = nullptr; - EXPECT_EQ(extRecordMgr->GetHostBundleNameForExtensionId(extensionRecordId, hostBundleName), ERR_INVALID_VALUE); + EXPECT_EQ(extRecordMgr->GetHostPidForExtensionId(extensionRecordId, hostPid), ERR_INVALID_VALUE); extRecordMgr->extensionRecords_[extensionRecordId] = extRecord; - EXPECT_EQ(extRecordMgr->GetHostBundleNameForExtensionId(extensionRecordId, hostBundleName), ERR_OK); + EXPECT_EQ(extRecordMgr->GetHostPidForExtensionId(extensionRecordId, hostPid), ERR_OK); TAG_LOGI(AAFwkTag::TEST, "end."); } } // namespace AbilityRuntime diff --git a/test/unittest/ui_extension/extension_record_manager_test/extension_record_manager_test.cpp b/test/unittest/ui_extension/extension_record_manager_test/extension_record_manager_test.cpp index 248b2cd900..5d4ec1664c 100755 --- a/test/unittest/ui_extension/extension_record_manager_test/extension_record_manager_test.cpp +++ b/test/unittest/ui_extension/extension_record_manager_test/extension_record_manager_test.cpp @@ -255,8 +255,8 @@ HWTEST_F(ExtensionRecordManagerTest, GetAbilityRecordBySessionInfo_0100, TestSiz std::string bundleName = ""; extRecordMgr->GetOrCreateExtensionRecord(abilityRequest, bundleName, abilityRecord2, bLoaded); extRecordMgr->GetOrCreateExtensionRecord(abilityRequest2, bundleName, abilityRecord2, bLoaded); - bundleName = ""; - extRecordMgr->GetHostBundleNameForExtensionId(extensionRecordId, bundleName); + int32_t hostPid = 0; + extRecordMgr->GetHostPidForExtensionId(extensionRecordId, hostPid); } /** @@ -450,8 +450,9 @@ HWTEST_F(ExtensionRecordManagerTest, IsPreloadExtensionRecord_0100, TestSize.Lev std::shared_ptr extRecord = std::make_shared(abilityRecord); std::string hostBundleName = "testHostBundleName"; bool isLoaded = false; + int32_t hostPid = 0; - bool result = extRecordMgr->IsPreloadExtensionRecord(abilityRequest, hostBundleName, extRecord, isLoaded); + bool result = extRecordMgr->IsPreloadExtensionRecord(abilityRequest, hostPid, extRecord, isLoaded); EXPECT_FALSE(result); std::string deviceId = "testDeviceId"; @@ -459,23 +460,23 @@ HWTEST_F(ExtensionRecordManagerTest, IsPreloadExtensionRecord_0100, TestSize.Lev std::string abilityName = "testAbilityName"; std::string moduleName = "testModuleName"; abilityRequest.want.SetElementName(deviceId, bundleName, abilityName, moduleName); - auto extensionRecordMapKey = std::make_tuple(abilityName, bundleName, moduleName, hostBundleName); + auto extensionRecordMapKey = std::make_tuple(abilityName, bundleName, moduleName, hostPid); std::vector> nullExtensions; std::vector> extensions; extensions.push_back(extRecord); extRecordMgr->preloadUIExtensionMap_.insert({extensionRecordMapKey, extensions}); - result = extRecordMgr->IsPreloadExtensionRecord(abilityRequest, hostBundleName, extRecord, isLoaded); + result = extRecordMgr->IsPreloadExtensionRecord(abilityRequest, hostPid, extRecord, isLoaded); EXPECT_TRUE(isLoaded); EXPECT_TRUE(result); extRecordMgr->preloadUIExtensionMap_[extensionRecordMapKey] = nullExtensions; - result = extRecordMgr->IsPreloadExtensionRecord(abilityRequest, hostBundleName, extRecord, isLoaded); + result = extRecordMgr->IsPreloadExtensionRecord(abilityRequest, hostPid, extRecord, isLoaded); EXPECT_FALSE(result); nullExtensions.push_back(nullptr); extRecordMgr->preloadUIExtensionMap_[extensionRecordMapKey] = nullExtensions; - result = extRecordMgr->IsPreloadExtensionRecord(abilityRequest, hostBundleName, extRecord, isLoaded); + result = extRecordMgr->IsPreloadExtensionRecord(abilityRequest, hostPid, extRecord, isLoaded); EXPECT_FALSE(result); } @@ -510,6 +511,7 @@ HWTEST_F(ExtensionRecordManagerTest, GetOrCreateExtensionRecord_0100, TestSize.L std::shared_ptr extRecord = std::make_shared(abilityRecord); extRecord->abilityRecord_ = abilityRecord; + int32_t hostPid = 0; std::string hostBundleName = "testHostBundleName"; bool isLoaded = false; @@ -519,7 +521,7 @@ HWTEST_F(ExtensionRecordManagerTest, GetOrCreateExtensionRecord_0100, TestSize.L std::string moduleName = "testModuleName"; abilityRequest.want.SetElementName(deviceId, bundleName, abilityName, moduleName); auto extensionRecordMapKey = std::make_tuple(abilityName, - bundleName, moduleName, hostBundleName); + bundleName, moduleName, hostPid); std::vector> nullExtensions; std::vector> extensions; @@ -527,7 +529,7 @@ HWTEST_F(ExtensionRecordManagerTest, GetOrCreateExtensionRecord_0100, TestSize.L extRecordMgr->preloadUIExtensionMap_.insert({extensionRecordMapKey, extensions}); auto ret = extRecordMgr->GetOrCreateExtensionRecord(abilityRequest, hostBundleName, abilityRecord, isLoaded); - EXPECT_EQ(ret, ERR_OK); + EXPECT_NE(ret, ERR_OK); } /**