Bugfix: add continuable check for sink

(cherry picked commit from <gitee.com//openharmony/ability_dmsfwk/commit/55260c83ba2d22a904b915a47378f4d1f338a4fd>

Signed-off-by: z00838083 <zhuhuixuan@huawei.com>
This commit is contained in:
z00838083 2024-10-18 18:42:30 +08:00
parent a3aec60d33
commit 1bbe6ac771
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)
{