!6236 The AuthManager fails to be obtains when the HML is established after the P2P link is established

Merge pull request !6236 from xzh/2405243
This commit is contained in:
openharmony_ci 2024-05-25 10:34:29 +00:00 committed by Gitee
commit ea9e381e64
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
13 changed files with 55 additions and 3 deletions

View File

@ -87,6 +87,7 @@ int32_t AuthDevicePostTransData(AuthHandle authHandle, const AuthTransData *data
void AuthDeviceCloseConn(AuthHandle authHandle);
int32_t AuthDeviceGetPreferConnInfo(const char *uuid, AuthConnInfo *connInfo);
int32_t AuthDeviceGetP2pConnInfo(const char *uuid, AuthConnInfo *connInfo);
int32_t AuthDeviceGetHmlConnInfo(const char *uuid, AuthConnInfo *connInfo);
/*check whether AUTH device is exist or not*/
bool AuthDeviceCheckConnInfo(const char* uuid, AuthLinkType type, bool checkConnection);

View File

@ -176,6 +176,7 @@ int32_t AuthPostTransData(AuthHandle authHandle, const AuthTransData *dataInfo);
void AuthCloseConn(AuthHandle authHandle);
int32_t AuthGetPreferConnInfo(const char *uuid, AuthConnInfo *connInfo, bool isMeta);
int32_t AuthGetP2pConnInfo(const char *uuid, AuthConnInfo *connInfo, bool isMeta);
int32_t AuthGetHmlConnInfo(const char *uuid, AuthConnInfo *connInfo, bool isMeta);
int32_t AuthGetLatestAuthSeqList(const char *udid, int64_t *seqList, uint32_t num);
int32_t AuthGetLatestAuthSeqListByType(const char *udid, int64_t *seqList, uint64_t *authVerifyTime,
DiscoveryType type);

View File

@ -296,6 +296,14 @@ int32_t AuthGetP2pConnInfo(const char *uuid, AuthConnInfo *connInfo, bool isMeta
return AuthDeviceGetP2pConnInfo(uuid, connInfo);
}
int32_t AuthGetHmlConnInfo(const char *uuid, AuthConnInfo *connInfo, bool isMeta)
{
if (isMeta) {
return AUTH_INVALID_ID;
}
return AuthDeviceGetHmlConnInfo(uuid, connInfo);
}
/* for ProxyChannel & P2P TcpDirectchannel */
void AuthGetLatestIdByUuid(const char *uuid, AuthLinkType type, bool isMeta, AuthHandle *authHandle)
{

View File

@ -2203,6 +2203,19 @@ int32_t GetAuthLinkTypeList(const char *networkId, AuthLinkTypeList *linkTypeLis
}
int32_t AuthDeviceGetP2pConnInfo(const char *uuid, AuthConnInfo *connInfo)
{
if (uuid == NULL || uuid[0] == '\0' || connInfo == NULL) {
AUTH_LOGE(AUTH_CONN, "invalid uuid or connInfo");
return SOFTBUS_INVALID_PARAM;
}
int32_t ret = GetAuthConnInfoByUuid(uuid, AUTH_LINK_TYPE_P2P, connInfo);
if (ret == SOFTBUS_OK) {
AUTH_LOGI(AUTH_CONN, "select auth type=%{public}d", AUTH_LINK_TYPE_P2P);
}
return ret;
}
int32_t AuthDeviceGetHmlConnInfo(const char *uuid, AuthConnInfo *connInfo)
{
if (uuid == NULL || uuid[0] == '\0' || connInfo == NULL) {
AUTH_LOGE(AUTH_CONN, "invalid uuid or connInfo");

View File

@ -131,6 +131,14 @@ int32_t AuthGetP2pConnInfo(const char *uuid, AuthConnInfo *connInfo, bool isMeta
return SOFTBUS_NOT_IMPLEMENT;
}
int32_t AuthGetHmlConnInfo(const char *uuid, AuthConnInfo *connInfo, bool isMeta)
{
(void)uuid;
(void)connInfo;
(void)isMeta;
return SOFTBUS_NOT_IMPLEMENT;
}
void AuthGetLatestIdByUuid(const char *uuid, AuthLinkType type, bool isMeta, AuthHandle *authHandle)
{
(void)uuid;

View File

@ -152,7 +152,7 @@ static int32_t GetPreferAuthConnInfo(const char *networkId, AuthConnInfo *connIn
LNN_LOGE(LNN_LANE, "get peer uuid fail");
return SOFTBUS_LANE_GET_LEDGER_INFO_ERR;
}
int32_t ret = AuthGetP2pConnInfo(uuid, connInfo, isMetaAuth);
int32_t ret = AuthGetHmlConnInfo(uuid, connInfo, isMetaAuth);
if (ret != SOFTBUS_OK) {
ret = AuthGetPreferConnInfo(uuid, connInfo, isMetaAuth);
}

View File

@ -417,8 +417,9 @@ static int32_t OpenAuthConn(const char *uuid, uint32_t reqId, bool isMeta)
(void)memset_s(&auth, sizeof(AuthConnInfo), 0, sizeof(AuthConnInfo));
AuthConnCallback cb;
(void)memset_s(&cb, sizeof(AuthConnCallback), 0, sizeof(AuthConnCallback));
int32_t ret = AuthGetP2pConnInfo(uuid, &auth, isMeta);
if (ret != SOFTBUS_OK && AuthGetPreferConnInfo(uuid, &auth, isMeta) != SOFTBUS_OK) {
if (AuthGetHmlConnInfo(uuid, &auth, isMeta) != SOFTBUS_OK &&
AuthGetP2pConnInfo(uuid, &auth, isMeta) != SOFTBUS_OK &&
AuthGetPreferConnInfo(uuid, &auth, isMeta) != SOFTBUS_OK) {
TRANS_LOGE(TRANS_CTRL, "get auth info fail");
return SOFTBUS_ERR;
}

View File

@ -838,6 +838,9 @@ static int32_t UdpOpenAuthConn(const char *peerUdid, uint32_t requestId, bool is
int32_t ret = SOFTBUS_ERR;
if (linkType == LANE_HML || linkType == LANE_P2P_REUSE) {
TRANS_LOGI(TRANS_CTRL, "get AuthConnInfo, linkType=%{public}d", linkType);
ret = AuthGetHmlConnInfo(peerUdid, &auth, isMeta);
}
if (ret != SOFTBUS_OK && (linkType == LANE_P2P || linkType == LANE_P2P_REUSE)) {
ret = AuthGetP2pConnInfo(peerUdid, &auth, isMeta);
}
if (ret != SOFTBUS_OK) {

View File

@ -486,6 +486,9 @@ HWTEST_F(AuthManagerTest, AUTH_DEVICE_GET_P2P_CONN_INFO_TEST_001, TestSize.Level
EXPECT_TRUE(AuthDeviceGetP2pConnInfo(nullptr, &connInfo) == SOFTBUS_INVALID_PARAM);
EXPECT_TRUE(AuthDeviceGetP2pConnInfo(UUID_TEST, nullptr) == SOFTBUS_INVALID_PARAM);
EXPECT_TRUE(AuthDeviceGetP2pConnInfo(UUID_TEST, &connInfo) == SOFTBUS_AUTH_NOT_FOUND);
EXPECT_TRUE(AuthDeviceGetHmlConnInfo(nullptr, &connInfo) == SOFTBUS_INVALID_PARAM);
EXPECT_TRUE(AuthDeviceGetHmlConnInfo(UUID_TEST, nullptr) == SOFTBUS_INVALID_PARAM);
EXPECT_TRUE(AuthDeviceGetHmlConnInfo(UUID_TEST, &connInfo) == SOFTBUS_AUTH_NOT_FOUND);
AuthSessionInfo info;
connInfo.type = AUTH_LINK_TYPE_WIFI;
info.connInfo.type = AUTH_LINK_TYPE_WIFI;

View File

@ -53,6 +53,7 @@ public:
virtual int32_t LnnGetRemoteStrInfo(const char *netWorkId, InfoKey key, char *info, uint32_t len) = 0;
virtual int32_t AuthGetPreferConnInfo(const char *uuid, AuthConnInfo *connInfo, bool isMeta) = 0;
virtual int32_t AuthGetP2pConnInfo(const char *uuid, AuthConnInfo *connInfo, bool isMeta) = 0;
virtual int32_t AuthGetHmlConnInfo(const char *uuid, AuthConnInfo *connInfo, bool isMeta) = 0;
virtual int32_t AuthOpenConn(const AuthConnInfo *info, uint32_t requestId,
const AuthConnCallback *callback, bool isMeta) = 0;
virtual int SoftBusFrequencyToChannel(int frequency) = 0;
@ -103,6 +104,7 @@ public:
MOCK_METHOD4(LnnGetRemoteStrInfo, int32_t (const char*, InfoKey, char*, uint32_t));
MOCK_METHOD3(AuthGetPreferConnInfo, int32_t (const char*, AuthConnInfo*, bool));
MOCK_METHOD3(AuthGetP2pConnInfo, int32_t (const char*, AuthConnInfo*, bool));
MOCK_METHOD3(AuthGetHmlConnInfo, int32_t (const char*, AuthConnInfo*, bool));
MOCK_METHOD4(AuthOpenConn, int32_t (const AuthConnInfo*, uint32_t, const AuthConnCallback*, bool));
MOCK_METHOD1(SoftBusFrequencyToChannel, int (int));
MOCK_METHOD2(LnnGetLocalNumInfo, int32_t (InfoKey, int32_t*));

View File

@ -202,6 +202,11 @@ int32_t AuthGetP2pConnInfo(const char *uuid, AuthConnInfo *connInfo, bool isMeta
return GetLaneDepsInterface()->AuthGetP2pConnInfo(uuid, connInfo, isMeta);
}
int32_t AuthGetHmlConnInfo(const char *uuid, AuthConnInfo *connInfo, bool isMeta)
{
return GetLaneDepsInterface()->AuthGetHmlConnInfo(uuid, connInfo, isMeta);
}
int32_t AuthOpenConn(const AuthConnInfo *info, uint32_t requestId,
const AuthConnCallback *callback, bool isMeta)
{

View File

@ -51,6 +51,7 @@ public:
virtual int32_t AuthPostTransData(AuthHandle authHandle, const AuthTransData *dataInfo) = 0;
virtual int32_t AuthGetPreferConnInfo(const char *uuid, AuthConnInfo *connInfo, bool isMeta) = 0;
virtual int32_t AuthGetP2pConnInfo(const char *uuid, AuthConnInfo *connInfo, bool isMeta) = 0;
virtual int32_t AuthGetHmlConnInfo(const char *uuid, AuthConnInfo *connInfo, bool isMeta) = 0;
virtual void AuthGetLatestIdByUuid(const char *uuid, bool isIpConnection, bool isMeta, AuthHandle *authHandle) = 0;
virtual int64_t AuthGetIdByConnInfo(const AuthConnInfo *connInfo, bool isServer, bool isMeta) = 0;
@ -113,6 +114,7 @@ public:
MOCK_METHOD2(AuthPostTransData, int32_t (AuthHandle, const AuthTransData *));
MOCK_METHOD3(AuthGetPreferConnInfo, int32_t (const char *, AuthConnInfo *, bool));
MOCK_METHOD3(AuthGetP2pConnInfo, int32_t (const char *, AuthConnInfo *, bool));
MOCK_METHOD3(AuthGetHmlConnInfo, int32_t (const char *, AuthConnInfo *, bool));
MOCK_METHOD4(AuthGetLatestIdByUuid, void (const char *, AuthLinkType, bool, AuthHandle *));
MOCK_METHOD3(AuthGetIdByConnInfo, int64_t (const AuthConnInfo *, bool, bool));

View File

@ -126,6 +126,11 @@ int32_t AuthGetP2pConnInfo(const char *uuid, AuthConnInfo *connInfo, bool isMeta
return GetTransAuthInterface()->AuthGetP2pConnInfo(uuid, connInfo, isMeta);
}
int32_t AuthGetHmlConnInfo(const char *uuid, AuthConnInfo *connInfo, bool isMeta)
{
return GetTransAuthInterface()->AuthGetHmlConnInfo(uuid, connInfo, isMeta);
}
void AuthGetLatestIdByUuid(const char *uuid, bool isIpConnection, bool isMeta, AuthHandle *authHandle)
{
return GetTransAuthInterface()->AuthGetLatestIdByUuid(uuid, isIpConnection, isMeta, authHandle);