!1161 Bugfix: 接收端增加continuable标签校验(5.0.1 release)

Merge pull request !1161 from zhx/cherry-pick-1730886258
This commit is contained in:
openharmony_ci 2024-11-15 06:44:56 +00:00 committed by Gitee
commit e1e7ce22f4
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 20 additions and 4 deletions

View File

@ -513,6 +513,10 @@ enum {
* Result(29360234) for mission is not focused.
*/
MISSION_NOT_FOCUSED = 29360234,
/**
* Result(29360235) for bundle is not continuable.
*/
BUNDLE_NOT_CONTINUABLE = 29360235,
};
} // namespace DistributedSchedule
} // namespace OHOS

View File

@ -104,6 +104,7 @@ private:
int32_t DealOnBroadcastBusiness(const std::string& senderNetworkId, uint16_t bundleNameId, uint8_t continueTypeId,
const int32_t state, const int32_t retry = 0);
void NotifyRecvBroadcast(const sptr<IRemoteObject>& obj, const currentIconInfo& continueInfo, const int32_t state);
bool IsBundleContinuable(const AppExecFwk::BundleInfo& bundleInfo);
private:
currentIconInfo iconInfo_;
sptr<DistributedMissionDiedListener> missionDiedListener_;

View File

@ -326,7 +326,6 @@ int32_t DMSContinueRecvMgr::DealOnBroadcastBusiness(const std::string& senderNet
return REMOTE_DEVICE_BIND_ABILITY_ERR;
}
HILOGI("get bundleName, bundleName: %{public}s", bundleName.c_str());
AppExecFwk::BundleInfo localBundleInfo;
std::string continueType;
FindContinueType(distributedBundleInfo, continueTypeId, continueType);
@ -340,6 +339,10 @@ int32_t DMSContinueRecvMgr::DealOnBroadcastBusiness(const std::string& senderNet
HILOGE("The bundleType must be app, but it is %{public}d", localBundleInfo.applicationInfo.bundleType);
return INVALID_PARAMETERS_ERR;
}
if (!IsBundleContinuable(localBundleInfo)) {
HILOGE("Bundle %{public}s is not continuable", finalBundleName.c_str());
return BUNDLE_NOT_CONTINUABLE;
}
int32_t ret = VerifyBroadcastSource(senderNetworkId, bundleName, finalBundleName, continueType, state);
if (ret != ERR_OK) {
@ -353,14 +356,22 @@ int32_t DMSContinueRecvMgr::DealOnBroadcastBusiness(const std::string& senderNet
}
std::vector<sptr<IRemoteObject>> objs = iterItem->second;
for (auto iter : objs) {
NotifyRecvBroadcast(iter,
currentIconInfo(senderNetworkId, bundleName, finalBundleName, continueType),
state);
NotifyRecvBroadcast(iter, currentIconInfo(senderNetworkId, bundleName, finalBundleName, continueType), state);
}
HILOGI("DealOnBroadcastBusiness end");
return ERR_OK;
}
bool DMSContinueRecvMgr::IsBundleContinuable(const AppExecFwk::BundleInfo& bundleInfo)
{
for (auto abilityInfo : bundleInfo.abilityInfos) {
if (abilityInfo.continuable) {
return true;
}
}
return false;
}
void DMSContinueRecvMgr::NotifyRecvBroadcast(const sptr<IRemoteObject>& obj,
const currentIconInfo& continueInfo, const int32_t state)
{