!7834 wifiDirect disconnect check if need auth channel

Merge pull request !7834 from 席国冬/master
This commit is contained in:
openharmony_ci 2024-09-24 11:16:01 +00:00 committed by Gitee
commit 1c9c048654
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 26 additions and 4 deletions

View File

@ -1161,6 +1161,21 @@ static void HandleActionTriggerError(uint32_t p2pRequestId)
}
}
static bool IsGuideChannelRetryErrcode(int32_t reason)
{
if (reason == SOFTBUS_CONN_ACTION_SEND_DATA_FAIL ||
reason == SOFTBUS_CONN_ACTION_STATUS_NO_ACK ||
reason == SOFTBUS_CONN_ACTION_STATUS_CHBA_SYNC ||
reason == SOFTBUS_CONN_AUTH_POST_DATA_FAILED ||
reason == SOFTBUS_CONN_HV2_SEND_TRIGGER_MSG_FAILED ||
reason == SOFTBUS_CONN_PV1_WAIT_CONNECT_RESPONSE_TIMEOUT ||
reason == SOFTBUS_CONN_PV2_WAIT_CONNECT_RESPONSE_TIMEOUT ||
reason == SOFTBUS_CONN_SOURCE_REUSE_LINK_FAILED) {
return true;
}
return false;
}
static void OnWifiDirectConnectFailure(uint32_t p2pRequestId, int32_t reason)
{
LNN_LOGI(LNN_LANE, "wifidirect conn fail, requestId=%{public}u, reason=%{public}d", p2pRequestId, reason);
@ -1179,9 +1194,7 @@ static void OnWifiDirectConnectFailure(uint32_t p2pRequestId, int32_t reason)
int32_t ret = LnnSyncPtk(reqInfo.laneRequestInfo.networkId);
LNN_LOGI(LNN_LANE, "syncptk done, ret=%{public}d", ret);
}
if (reason == SOFTBUS_CONN_SOURCE_REUSE_LINK_FAILED || reason == SOFTBUS_CONN_POST_DATA_FAILED ||
reason == SOFTBUS_CONN_PV1_WAIT_CONNECT_RESPONSE_TIMEOUT ||
reason == SOFTBUS_CONN_PV2_WAIT_CONNECT_RESPONSE_TIMEOUT) {
if (IsGuideChannelRetryErrcode(reason)) {
LNN_LOGI(LNN_LANE, "guide channel retry, requestId=%{public}u, reason=%{public}d", p2pRequestId, reason);
HandleGuideChannelAsyncFail(ASYNC_RESULT_P2P, p2pRequestId, reason);
return;
@ -2634,7 +2647,9 @@ int32_t LnnDisconnectP2p(const char *networkId, uint32_t laneReqId)
return SOFTBUS_STRCPY_ERR;
}
LinkUnlock();
if (linkType == LANE_HML_RAW || OpenAuthToDisconnP2p(networkId, linkId) != SOFTBUS_OK) {
enum WifiDirectLinkType type = (linkType == LANE_P2P) ? WIFI_DIRECT_LINK_TYPE_P2P : WIFI_DIRECT_LINK_TYPE_HML;
if (linkType == LANE_HML_RAW || !GetWifiDirectManager()->isNegotiateChannelNeeded(networkId, type) ||
OpenAuthToDisconnP2p(networkId, linkId) != SOFTBUS_OK) {
int32_t errCode = DisconnectP2pWithoutAuthConn(pid, mac, linkId);
if (errCode != SOFTBUS_OK) {
DelP2pLinkedByLinkId(linkId);

View File

@ -119,6 +119,11 @@ static bool IsNegotiateChannelNeeded(const char *remoteNetworkId, enum WifiDirec
return false;
}
static bool IsNegotiateChannelNeededTrue(const char *remoteNetworkId, enum WifiDirectLinkType linkType)
{
return true;
}
static uint32_t GetRequestId(void)
{
return 1;
@ -1160,6 +1165,7 @@ HWTEST_F(LNNLaneLinkTest, GuideChannelRetryOfAsync_007, TestSize.Level1)
EXPECT_CALL(linkMock, AuthGenRequestId).WillRepeatedly(Return(requestId));
EXPECT_CALL(linkMock, AuthOpenConn(_, requestId, NotNull(), _)).WillOnce(linkMock.ActionOfConnOpenFailed)
.WillRepeatedly(Return(SOFTBUS_OK));
g_manager.isNegotiateChannelNeeded = IsNegotiateChannelNeededTrue;
EXPECT_CALL(linkMock, GetWifiDirectManager).WillRepeatedly(Return(&g_manager));
EXPECT_CALL(linkMock, AuthGetHmlConnInfo).WillRepeatedly(Return(SOFTBUS_OK));
EXPECT_CALL(linkMock, AuthGetP2pConnInfo).WillRepeatedly(Return(SOFTBUS_OK));
@ -1170,6 +1176,7 @@ HWTEST_F(LNNLaneLinkTest, GuideChannelRetryOfAsync_007, TestSize.Level1)
EXPECT_EQ(SOFTBUS_OK, g_laneLinkResult);
LnnDisconnectP2p(NODE_NETWORK_ID, laneReqId);
LnnDestroyP2p();
g_manager.isNegotiateChannelNeeded = IsNegotiateChannelNeeded;
}
/*