IssueNo:#I5AHJK:StartAbilityByCall interface cannot get caller when its input want includes moduleName

Description:StartAbilityByCall interface cannot get caller when its input want includes moduleName
Sig:SIG_ApplicationFramework
Feature or Bugfix:Feature
Binary Source:No

Signed-off-by: zhoujun62 <zhoujun62@huawei.com>
Change-Id: Ic33622d8e7174e87f4142a1cd0c0da4f5ef71ac0
This commit is contained in:
zhoujun62 2022-06-28 15:41:07 +08:00
parent 0f28efd18f
commit 6bc18d6166
5 changed files with 22 additions and 15 deletions

View File

@ -230,8 +230,7 @@ bool ConnectionManager::IsConnectReceiverEqual(const AppExecFwk::ElementName &co
const AppExecFwk::ElementName &connectReceiverOther)
{
return connectReceiver.GetBundleName() == connectReceiverOther.GetBundleName() &&
connectReceiver.GetAbilityName() == connectReceiverOther.GetAbilityName() &&
connectReceiver.GetModuleName() == connectReceiverOther.GetModuleName();
connectReceiver.GetAbilityName() == connectReceiverOther.GetAbilityName();
}
ErrCode ConnectionManager::HandleCallbackTimeOut(const sptr<IRemoteObject> &connectCaller, const AAFwk::Want &want,

View File

@ -175,10 +175,19 @@ void LocalCallContainer::OnAbilityDisconnectDone(const AppExecFwk::ElementName &
bool LocalCallContainer::GetCallLocalRecord(
const AppExecFwk::ElementName &elementName, std::shared_ptr<LocalCallRecord> &localCallRecord)
{
auto iter = callProxyRecords_.find(elementName.GetURI());
if (iter != callProxyRecords_.end() && iter->second != nullptr) {
localCallRecord = iter->second;
return true;
for (auto pair : callProxyRecords_) {
AppExecFwk::ElementName callElement;
if (!callElement.ParseURI(pair.first)) {
HILOG_ERROR("Parse uri to elementName failed, elementName uri: %{public}s", pair.first.c_str());
return false;
}
// elementName in callProxyRecords_ has moduleName (sometimes not empty),
// but the moduleName of input param elementName is usually empty.
callElement.SetModuleName("");
if ((pair.first == elementName.GetURI() || callElement.GetURI() == elementName.GetURI()) && pair.second) {
localCallRecord = pair.second;
return true;
}
}
return false;
}

View File

@ -1249,13 +1249,11 @@ void JSAbilityConnection::HandleOnAbilityDisconnectDone(const AppExecFwk::Elemen
HILOG_INFO("OnAbilityDisconnectDone abilityConnects_.size:%{public}zu", abilityConnects_.size());
std::string bundleName = element.GetBundleName();
std::string abilityName = element.GetAbilityName();
std::string moduleName = element.GetModuleName();
auto item = std::find_if(abilityConnects_.begin(), abilityConnects_.end(),
[bundleName, abilityName, moduleName] (
[bundleName, abilityName] (
const std::map<ConnectionKey, sptr<JSAbilityConnection>>::value_type &obj) {
return (bundleName == obj.first.want.GetBundle()) &&
(abilityName == obj.first.want.GetElement().GetAbilityName()) &&
(moduleName == obj.first.want.GetElement().GetModuleName());
(abilityName == obj.first.want.GetElement().GetAbilityName());
});
if (item != abilityConnects_.end()) {
// match bundlename && abilityname

View File

@ -782,14 +782,12 @@ void JSServiceExtensionConnection::HandleOnAbilityDisconnectDone(const AppExecFw
HILOG_INFO("OnAbilityDisconnectDone connects_.size:%{public}zu", connects_.size());
std::string bundleName = element.GetBundleName();
std::string abilityName = element.GetAbilityName();
std::string moduleName = element.GetModuleName();
auto item = std::find_if(connects_.begin(),
connects_.end(),
[bundleName, abilityName, moduleName](
[bundleName, abilityName](
const std::map<ConnecttionKey, sptr<JSServiceExtensionConnection>>::value_type &obj) {
return (bundleName == obj.first.want.GetBundle()) &&
(abilityName == obj.first.want.GetElement().GetAbilityName()) &&
(moduleName == obj.first.want.GetElement().GetModuleName());
(abilityName == obj.first.want.GetElement().GetAbilityName());
});
if (item != connects_.end()) {
// match bundlename && abilityname

View File

@ -217,7 +217,10 @@ std::shared_ptr<AbilityRecord> MissionList::GetAbilityRecordByName(const AppExec
const AppExecFwk::AbilityInfo &abilityInfo = mission->GetAbilityRecord()->GetAbilityInfo();
AppExecFwk::ElementName localElement(abilityInfo.deviceId, abilityInfo.bundleName,
abilityInfo.name, abilityInfo.moduleName);
if (localElement == element) {
AppExecFwk::ElementName localElementNoModuleName(abilityInfo.deviceId,
abilityInfo.bundleName, abilityInfo.name); // note: moduleName of input param element maybe empty
if (localElement == element || localElementNoModuleName == element) {
return mission->GetAbilityRecord();
}
}