diff --git a/common/include/dtbschedmgr_log.h b/common/include/dtbschedmgr_log.h index b6fb62a8..2ab01da2 100644 --- a/common/include/dtbschedmgr_log.h +++ b/common/include/dtbschedmgr_log.h @@ -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 diff --git a/services/dtbschedmgr/src/continue/dsched_continue_manager.cpp b/services/dtbschedmgr/src/continue/dsched_continue_manager.cpp index 4dffd0dd..277edf83 100644 --- a/services/dtbschedmgr/src/continue/dsched_continue_manager.cpp +++ b/services/dtbschedmgr/src/continue/dsched_continue_manager.cpp @@ -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) diff --git a/services/dtbschedmgr/src/softbus_adapter/allconnectmgr/dsched_all_connect_manager.cpp b/services/dtbschedmgr/src/softbus_adapter/allconnectmgr/dsched_all_connect_manager.cpp index 6f703b1c..2e9c6af3 100644 --- a/services/dtbschedmgr/src/softbus_adapter/allconnectmgr/dsched_all_connect_manager.cpp +++ b/services/dtbschedmgr/src/softbus_adapter/allconnectmgr/dsched_all_connect_manager.cpp @@ -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.", diff --git a/services/dtbschedmgr/test/unittest/continue/dsched_continue_manager_test.cpp b/services/dtbschedmgr/test/unittest/continue/dsched_continue_manager_test.cpp index 308c82f8..334e1049 100644 --- a/services/dtbschedmgr/test/unittest/continue/dsched_continue_manager_test.cpp +++ b/services/dtbschedmgr/test/unittest/continue/dsched_continue_manager_test.cpp @@ -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);