!5047 单单分享联调适配

Merge pull request !5047 from 黄凯/master
This commit is contained in:
openharmony_ci 2024-01-13 14:25:31 +00:00 committed by Gitee
commit 95d88be72f
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 46 additions and 10 deletions

View File

@ -39,6 +39,7 @@ int32_t TransCloseAuthChannel(int32_t channelId);
int32_t TransSendAuthMsg(int32_t channelId, const char *msg, int32_t len);
int32_t TransAuthGetAppInfoByChanId(int32_t channelId, AppInfo *appInfo);
int32_t TransAuthGetConnOptionByChanId(int32_t channelId, ConnectOption *connOpt);
int32_t TransAuthGetConnIdByChanId(int32_t channelId, int32_t *connId);
#ifdef __cplusplus
#if __cplusplus

View File

@ -925,3 +925,27 @@ int32_t TransAuthGetAppInfoByChanId(int32_t channelId, AppInfo *appInfo)
return SOFTBUS_ERR;
}
int32_t TransAuthGetConnIdByChanId(int32_t channelId, int32_t *connId)
{
if ((g_authChannelList == NULL) || (connId == NULL)) {
TRANS_LOGE(TRANS_SVC, "invalid param");
return SOFTBUS_INVALID_PARAM;
}
if (SoftBusMutexLock(&g_authChannelList->lock) != 0) {
TRANS_LOGE(TRANS_SVC, "get mutex lock failed");
return SOFTBUS_LOCK_ERR;
}
AuthChannelInfo *item = NULL;
LIST_FOR_EACH_ENTRY(item, &g_authChannelList->list, AuthChannelInfo, node) {
if (item->appInfo.myData.channelId == channelId) {
*connId = item->authId;
(void)SoftBusMutexUnlock(&g_authChannelList->lock);
return SOFTBUS_OK;
}
}
SoftBusMutexUnlock(&g_authChannelList->lock);
TRANS_LOGE(TRANS_SVC, "get connid failed");
return SOFTBUS_ERR;
}

View File

@ -395,14 +395,15 @@ static int32_t GetRequestOptionBySessionParam(const SessionParam *param, LaneReq
requestOption->requestInfo.trans.acceptableProtocols = LNN_PROTOCOL_ALL ^ LNN_PROTOCOL_NIP;
TransGetQosInfo(param, &requestOption->requestInfo.trans.qosRequire, isQosLane);
NodeInfo *info = LnnGetNodeInfoById(requestOption->requestInfo.trans.networkId, CATEGORY_NETWORK_ID);
if (info != NULL && LnnHasDiscoveryType(info, DISCOVERY_TYPE_LSA)) {
NodeInfo info;
int32_t ret = LnnGetRemoteNodeInfoById(requestOption->requestInfo.trans.networkId, CATEGORY_NETWORK_ID, &info);
if ((ret == SOFTBUS_OK) && LnnHasDiscoveryType(&info, DISCOVERY_TYPE_LSA)) {
requestOption->requestInfo.trans.acceptableProtocols |= LNN_PROTOCOL_NIP;
}
// ble mac is used when linktype is LINK_TYPE_BLE
TransGetBleMac(param, requestOption);
int32_t uid;
int32_t ret = TransGetUidAndPid(param->sessionName, &uid, &(requestOption->requestInfo.trans.pid));
ret = TransGetUidAndPid(param->sessionName, &uid, &(requestOption->requestInfo.trans.pid));
if (ret != SOFTBUS_OK) {
TRANS_LOGE(TRANS_SVC, "transGetUidAndPid failed.");
return ret;

View File

@ -850,13 +850,23 @@ int32_t TransGetAppInfoByChanId(int32_t channelId, int32_t channelType, AppInfo*
int32_t TransGetConnByChanId(int32_t channelId, int32_t channelType, int32_t* connId)
{
if (channelType != CHANNEL_TYPE_PROXY) {
TRANS_LOGE(TRANS_CTRL, "channelType error. channelType=%{public}d", channelType);
return SOFTBUS_ERR;
int32_t ret;
switch (channelType) {
case CHANNEL_TYPE_PROXY:
ret = TransProxyGetConnIdByChanId(channelId, connId);
break;
case CHANNEL_TYPE_AUTH:
ret = TransAuthGetConnIdByChanId(channelId, connId);
break;
default:
TRANS_LOGE(TRANS_CTRL, "channelType=%{public}d error", channelType);
ret = SOFTBUS_ERR;
}
if (TransProxyGetConnIdByChanId(channelId, connId) != SOFTBUS_OK) {
TRANS_LOGE(TRANS_MSG, "get proxy connId, channelId=%{public}d", channelId);
return SOFTBUS_TRANS_PROXY_SEND_CHANNELID_INVALID;
if (ret != SOFTBUS_OK) {
TRANS_LOGE(TRANS_MSG, "get connId failed, channelId=%{public}d, channelType=%{public}d",
channelId, channelType);
}
return SOFTBUS_OK;
return ret;
}