!1026 fix continue mission invaid src and dst error code

Merge pull request !1026 from 仝月姣/master
This commit is contained in:
openharmony_ci 2024-08-02 14:22:12 +00:00 committed by Gitee
commit bc430105e4
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 23 additions and 5 deletions

View File

@ -466,6 +466,10 @@ enum {
* Result(29360231) for all connect manager reject connect apply.
*/
DMS_CONNECT_APPLY_REJECT_FAILED = 29360231,
/**
* Result(29360232) for all connect manager reject connect apply.
*/
DMS_CONNECT_APPLY_TIMEOUT_FAILED = 29360232,
};
} // namespace DistributedSchedule
} // namespace OHOS

View File

@ -121,6 +121,11 @@ int32_t DSchedContinueManager::ContinueMission(const std::string& srcDeviceId, c
HILOGE("get local deviceId failed!");
return INVALID_PARAMETERS_ERR;
}
if (localDevId != srcDeviceId && localDevId != dstDeviceId) {
HILOGE("Input srcDevId: %{public}s or dstDevId: %{public}s must be locDevId: %{public}s.",
GetAnonymStr(srcDeviceId).c_str(), GetAnonymStr(dstDeviceId).c_str(), GetAnonymStr(localDevId).c_str());
return OPERATION_DEVICE_NOT_INITIATOR_OR_TARGET;
}
if (DtbschedmgrDeviceInfoStorage::GetInstance().GetDeviceInfoById(
localDevId == srcDeviceId ? dstDeviceId : srcDeviceId) == nullptr) {
HILOGE("GetDeviceInfoById fail, locDevId: %{public}s, srcDevId: %{public}s, dstDevId: %{public}s.",
@ -182,6 +187,11 @@ int32_t DSchedContinueManager::ContinueMission(const std::string& srcDeviceId, c
HILOGE("get local deviceId failed!");
return INVALID_PARAMETERS_ERR;
}
if (localDevId != srcDeviceId && localDevId != dstDeviceId) {
HILOGE("Input srcDevId: %{public}s or dstDevId: %{public}s must be locDevId: %{public}s.",
GetAnonymStr(srcDeviceId).c_str(), GetAnonymStr(dstDeviceId).c_str(), GetAnonymStr(localDevId).c_str());
return OPERATION_DEVICE_NOT_INITIATOR_OR_TARGET;
}
if (DtbschedmgrDeviceInfoStorage::GetInstance().GetDeviceInfoById(
localDevId == srcDeviceId ? dstDeviceId : srcDeviceId) == nullptr) {
HILOGE("GetDeviceInfoById fail, locDevId: %{public}s, srcDevId: %{public}s, dstDevId: %{public}s.",
@ -288,7 +298,7 @@ void DSchedContinueManager::WaitAllConnectDecision(int32_t direction, const DSch
peerConnectDecision_.erase(peerDeviceId);
}
#endif
SetTimeOut(info, CONTINUE_TIMEOUT);
SetTimeOut(info, timeout);
}
void DSchedContinueManager::SetTimeOut(const DSchedContinueInfo &info, int32_t timeout)

View File

@ -232,7 +232,7 @@ int32_t DSchedAllConnectManager::WaitAllConnectApplyCb(const std::string &peerNe
if (peerConnectDecision_.find(peerNetworkId) == peerConnectDecision_.end()) {
HILOGE("Not find peerNetworkId %{public}s in peerConnectDecision.", GetAnonymStr(peerNetworkId).c_str());
return CONTINUE_ABILITY_TIMEOUT_ERR;
return DMS_CONNECT_APPLY_TIMEOUT_FAILED;
}
int32_t ret = peerConnectDecision_.at(peerNetworkId).load() ? ERR_OK : DMS_CONNECT_APPLY_REJECT_FAILED;
HILOGI("Wait all connect apply decision callback end, peerNetworkId %{public}s, isSupport %{public}d.",

View File

@ -115,7 +115,7 @@ HWTEST_F(DSchedContinueManagerTest, ContinueMission_001, TestSize.Level3)
OHOS::AAFwk::WantParams wantParams;
int32_t ret = DSchedContinueManager::GetInstance().ContinueMission(LOCAL_DEVICEID, REMOTE_DEVICEID, MISSION_ID,
callback, wantParams);
EXPECT_EQ(ret, INVALID_REMOTE_PARAMETERS_ERR);
EXPECT_EQ(ret, OPERATION_DEVICE_NOT_INITIATOR_OR_TARGET);
DTEST_LOG << "DSchedContinueManagerTest ContinueMission_001 end" << std::endl;
}
@ -136,7 +136,7 @@ HWTEST_F(DSchedContinueManagerTest, ContinueMission_002, TestSize.Level3)
int32_t ret = DSchedContinueManager::GetInstance().ContinueMission(LOCAL_DEVICEID, REMOTE_DEVICEID, MISSION_ID,
callback, wantParams);
EXPECT_EQ(ret, INVALID_REMOTE_PARAMETERS_ERR);
EXPECT_EQ(ret, OPERATION_DEVICE_NOT_INITIATOR_OR_TARGET);
DTEST_LOG << "DSchedContinueManagerTest ContinueMission_002 end" << std::endl;
}
@ -165,10 +165,14 @@ HWTEST_F(DSchedContinueManagerTest, ContinueMission_003, TestSize.Level3)
auto callback = GetDSchedService();
ret = DSchedContinueManager::GetInstance().ContinueMission(LOCAL_DEVICEID, REMOTE_DEVICEID, BUNDLE_NAME,
CONTINUETYPE, callback, wantParams);
EXPECT_EQ(ret, INVALID_REMOTE_PARAMETERS_ERR);
EXPECT_EQ(ret, OPERATION_DEVICE_NOT_INITIATOR_OR_TARGET);
std::string locDevId;
EXPECT_EQ(true, DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(locDevId));
ret = DSchedContinueManager::GetInstance().ContinueMission(LOCAL_DEVICEID, locDevId, BUNDLE_NAME,
CONTINUETYPE, callback, wantParams);
EXPECT_EQ(ret, INVALID_REMOTE_PARAMETERS_ERR);
ret = DSchedContinueManager::GetInstance().ContinueMission(locDevId, REMOTE_DEVICEID, BUNDLE_NAME,
CONTINUETYPE, callback, wantParams);
EXPECT_EQ(ret, INVALID_REMOTE_PARAMETERS_ERR);