fix EUA preload issue

Signed-off-by: wlh2624_DS <1968860844@qq.com>
This commit is contained in:
wlh2624_DS
2025-11-15 18:13:19 +08:00
parent 8c42a4c9bf
commit a90ceec303
25 changed files with 128 additions and 126 deletions
@@ -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);
@@ -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)
{
@@ -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<AAFwk::AbilityRecord> &abilityRecord, std::string &bundleName);
int UnloadUIExtensionAbility(const std::shared_ptr<AAFwk::AbilityRecord> &abilityRecord, pid_t &hostPid);
/**
* ClearPreloadUIExtensionRecord, clear preload uiextension record.
@@ -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;
@@ -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<AAFwk::AbilityRecord> &abilityRecord, std::string &bundleName);
int UnloadUIExtensionAbility(const std::shared_ptr<AAFwk::AbilityRecord> &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;
@@ -32,7 +32,7 @@ namespace AbilityRuntime {
class ExtensionRecordManager : public std::enable_shared_from_this<ExtensionRecordManager> {
public:
using ExtensionAbilityRecordMap = std::map<int32_t, std::shared_ptr<ExtensionRecord>>;
using PreLoadUIExtensionMapKey = std::tuple<std::string, std::string, std::string, std::string>;
using PreLoadUIExtensionMapKey = std::tuple<std::string, std::string, std::string, pid_t>;
using PreLoadUIExtensionMapType =
std::map<PreLoadUIExtensionMapKey, std::vector<std::shared_ptr<ExtensionRecord>>>;
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> &extensionRecord, bool &isLoaded);
const pid_t &hostPid, std::shared_ptr<ExtensionRecord> &extensionRecord, bool &isLoaded);
int32_t AddPreloadUIExtensionRecord(const std::shared_ptr<AAFwk::AbilityRecord> abilityRecord);
void RemoveAllPreloadUIExtensionRecord(PreLoadUIExtensionMapKey &preLoadUIExtensionInfo);
bool RemovePreloadUIExtensionRecord(
const std::tuple<std::string, std::string, std::string, std::string> extensionRecordMapKey);
const std::tuple<std::string, std::string, std::string, pid_t> extensionRecordMapKey);
bool RemovePreloadUIExtensionRecordById(
const std::tuple<std::string, std::string, std::string, std::string> &extensionRecordMapKey,
const std::tuple<std::string, std::string, std::string, pid_t> &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<AAFwk::AbilityRecord> &abilityRecord,
std::list<sptr<IRemoteObject>> &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:
@@ -618,14 +618,14 @@ int AbilityConnectManager::PreloadUIExtensionAbilityInner(const AbilityRequest &
}
int AbilityConnectManager::UnloadUIExtensionAbility(const std::shared_ptr<AAFwk::AbilityRecord> &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<AbilityRecord> AbilityConnectManager::GetUIExtensionBySessionFromServiceMap(
@@ -2285,7 +2285,7 @@ ErrCode AbilityManagerClient::UnregisterHiddenStartObserver(const sptr<IHiddenSt
ErrCode AbilityManagerClient::QueryPreLoadUIExtensionRecord(const AppExecFwk::ElementName &element,
const std::string &moduleName,
const std::string &hostBundleName,
const int32_t hostPid,
int32_t &recordNum,
int32_t userId)
{
@@ -2293,7 +2293,7 @@ ErrCode AbilityManagerClient::QueryPreLoadUIExtensionRecord(const AppExecFwk::El
auto abms = GetAbilityManager();
CHECK_POINTER_RETURN_NOT_CONNECTED(abms);
return abms->QueryPreLoadUIExtensionRecord(
element, moduleName, hostBundleName, recordNum, userId);
element, moduleName, hostPid, recordNum, userId);
}
ErrCode AbilityManagerClient::RevokeDelegator(sptr<IRemoteObject> token)
@@ -6710,7 +6710,7 @@ int32_t AbilityManagerProxy::UnregisterHiddenStartObserver(const sptr<IHiddenSta
int32_t AbilityManagerProxy::QueryPreLoadUIExtensionRecord(const AppExecFwk::ElementName &element,
const std::string &moduleName,
const std::string &hostBundleName,
const int32_t hostPid,
int32_t &recordNum,
int32_t userId)
{
@@ -6733,8 +6733,8 @@ int32_t AbilityManagerProxy::QueryPreLoadUIExtensionRecord(const AppExecFwk::Ele
return ERR_INVALID_VALUE;
}
if (!data.WriteString(hostBundleName)) {
TAG_LOGE(AAFwkTag::UI_EXT, "write hostBundleName fail");
if (!data.WriteInt32(hostPid)) {
TAG_LOGE(AAFwkTag::UI_EXT, "write hostPid fail");
return INNER_ERR;
}
@@ -3693,7 +3693,7 @@ int AbilityManagerService::PreloadUIExtensionAbilityInner(const Want &want, std:
}
int AbilityManagerService::UnloadUIExtensionAbility(const std::shared_ptr<AAFwk::AbilityRecord> &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_ptr<AAFwk:
TAG_LOGE(AAFwkTag::ABILITYMGR, "connectManager null");
return ERR_INVALID_VALUE;
}
return connectManager->UnloadUIExtensionAbility(abilityRecord, hostBundleName);
return connectManager->UnloadUIExtensionAbility(abilityRecord, hostPid);
}
int AbilityManagerService::RequestModalUIExtension(const Want &want)
@@ -15258,7 +15258,7 @@ int32_t AbilityManagerService::UnregisterHiddenStartObserver(const sptr<IHiddenS
int32_t AbilityManagerService::QueryPreLoadUIExtensionRecord(const AppExecFwk::ElementName &element,
const std::string &moduleName,
const std::string &hostBundleName,
const int32_t hostPid,
int32_t &recordNum,
int32_t userId)
{
@@ -15277,7 +15277,7 @@ int32_t AbilityManagerService::QueryPreLoadUIExtensionRecord(const AppExecFwk::E
return ERR_INVALID_VALUE;
}
return connectManager->QueryPreLoadUIExtensionRecordInner(
element, moduleName, hostBundleName, recordNum);
element, moduleName, hostPid, recordNum);
}
int32_t AbilityManagerService::RevokeDelegator(sptr<IRemoteObject> token)
@@ -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;
@@ -62,7 +62,7 @@ void ExtensionRecord::UnloadUIExtensionAbility()
TAG_LOGE(AAFwkTag::ABILITYMGR, "unRegisterObserver error");
}
auto result = DelayedSingleton<AAFwk::AbilityManagerService>::GetInstance()->UnloadUIExtensionAbility(
abilityRecord_, hostBundleName_);
abilityRecord_, hostPid_);
if (result != ERR_OK) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "UIExtension unload error");
}
@@ -162,12 +162,13 @@ int32_t ExtensionRecordManager::GetOrCreateExtensionRecord(const AAFwk::AbilityR
}
std::shared_ptr<ExtensionRecord> 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<std::mutex> 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<std::mutex> 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> &extensionRecord, bool &isLoaded)
const pid_t &hostPid, std::shared_ptr<ExtensionRecord> &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<std::mutex> 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<std::string, std::string, std::string, std::string> &extensionRecordMapKey,
const std::tuple<std::string, std::string, std::string, pid_t> &extensionRecordMapKey,
int32_t extensionRecordId)
{
TAG_LOGD(AAFwkTag::ABILITYMGR, "call.");
@@ -400,7 +401,7 @@ bool ExtensionRecordManager::RemovePreloadUIExtensionRecordById(
}
bool ExtensionRecordManager::RemovePreloadUIExtensionRecord(
const std::tuple<std::string, std::string, std::string, std::string> extensionRecordMapKey)
const std::tuple<std::string, std::string, std::string, pid_t> extensionRecordMapKey)
{
TAG_LOGD(AAFwkTag::ABILITYMGR, "call.");
std::lock_guard<std::mutex> 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<std::mutex> lock(preloadUIExtensionMapMutex_);
auto item = preloadUIExtensionMap_.find(extensionRecordMapKey);
if (item != preloadUIExtensionMap_.end()) {
@@ -65,7 +65,7 @@ bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
sptr<IRemoteObject> focusedCallerToken;
sptr<IRemoteObject> token;
sptr<IRemoteObject> focusToken;
std::tuple<std::string, std::string, std::string, std::string> extensionRecordMapKey;
std::tuple<std::string, std::string, std::string, int32_t> extensionRecordMapKey;
FuzzedDataProvider fdp(data, size);
userId = fdp.ConsumeIntegral<int32_t>();
@@ -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
@@ -122,18 +122,18 @@ void FuzztestExtensionRecordManagerFunc2(std::shared_ptr<ExtensionRecordManager>
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
@@ -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);
}
@@ -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");
}
@@ -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");
}
@@ -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 = 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);
}
@@ -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<uint32_t>(AbilityManagerInterfaceCode::QUERY_PRELOAD_UIEXTENSION_RECORD), mock_->code_);
EXPECT_EQ(res, NO_ERROR);
}
@@ -1097,8 +1097,8 @@ HWTEST_F(AbilityManagerServiceThirdTest, UnloadUIExtensionAbility_001, TestSize.
abilityRequest.want.SetElement(providerElement);
abilityRequest.abilityInfo.type = AbilityType::EXTENSION;
std::shared_ptr<AbilityRecord> 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.");
}
@@ -132,7 +132,7 @@ int AbilityConnectManager::PreloadUIExtensionAbilityInner(const AbilityRequest &
}
int AbilityConnectManager::UnloadUIExtensionAbility(const std::shared_ptr<AAFwk::AbilityRecord> &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;
@@ -1080,7 +1080,7 @@ ErrCode AbilityManagerClient::UnregisterHiddenStartObserver(const sptr<IHiddenSt
ErrCode AbilityManagerClient::QueryPreLoadUIExtensionRecord(const AppExecFwk::ElementName &element,
const std::string &moduleName,
const std::string &hostBundleName,
const int32_t hostPid,
int32_t &recordNum,
int32_t userId)
{
@@ -219,7 +219,7 @@ HWTEST_F(ExtensionRecordManagerSecondTest, RemovePreloadUIExtensionRecordById_01
{
TAG_LOGI(AAFwkTag::TEST, "begin.");
auto extRecordMgr = std::make_shared<ExtensionRecordManager>(0);
std::tuple<std::string, std::string, std::string, std::string> extensionRecordMapKey;
std::tuple<std::string, std::string, std::string, int32_t> 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<ExtensionRecordManager>(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<ExtensionRecordManager>(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<ExtensionRecordManager>(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<ExtensionRecordManager>(0);
std::tuple<std::string, std::string, std::string, std::string> extensionRecordMapKey = {
"1", "2", "3", "4"
std::tuple<std::string, std::string, std::string, int32_t> 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<ExtensionRecordManager>(0);
std::tuple<std::string, std::string, std::string, std::string> extensionRecordMapKey = {
"1", "2", "3", "4"
std::tuple<std::string, std::string, std::string, int32_t> 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<ExtensionRecordManager>(0);
std::tuple<std::string, std::string, std::string, std::string> extensionRecordMapKey = {
"1", "2", "3", "4"
std::tuple<std::string, std::string, std::string, int32_t> 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<ExtensionRecordManager>(0);
std::tuple<std::string, std::string, std::string, std::string> extensionRecordMapKey = {
"1", "2", "3", "4"
std::tuple<std::string, std::string, std::string, int32_t> 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<ExtensionRecord> extRecord = std::make_shared<ExtensionRecord>(abilityRecord);
auto extRecordMgr = std::make_shared<ExtensionRecordManager>(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
@@ -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<ExtensionRecord> extRecord = std::make_shared<ExtensionRecord>(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<std::shared_ptr<ExtensionRecord>> nullExtensions;
std::vector<std::shared_ptr<ExtensionRecord>> 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<ExtensionRecord> extRecord =
std::make_shared<ExtensionRecord>(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<std::shared_ptr<ExtensionRecord>> nullExtensions;
std::vector<std::shared_ptr<ExtensionRecord>> 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);
}
/**