Merge branch 'master' of gitee.com:openharmony/communication_dsoftbus into master

Signed-off-by: xingchu <weiqian22@huawei.com>
This commit is contained in:
xingchu 2024-11-13 01:50:59 +00:00 committed by Gitee
commit 6c0e57252b
12 changed files with 162 additions and 99 deletions

View File

@ -31,7 +31,7 @@ static int32_t GetSvcIdentityByPkgName(const char *pkgName, SvcIdentity *svc)
struct CommonScvId svcId = {0};
if (SERVER_GetIdentityByPkgName(pkgName, &svcId) != SOFTBUS_OK) {
LNN_LOGE(LNN_EVENT, "get bus center callback failed");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_GET_SERVICE_IDENTITY_FAILED;
}
svc->handle = svcId.handle;
svc->token = svcId.token;
@ -54,7 +54,7 @@ static int32_t GetAllClientIdentity(SvcIdentity *svc, int num)
if (SERVER_GetAllClientIdentity(svcId, num) != SOFTBUS_OK) {
SoftBusFree(svcId);
LNN_LOGE(LNN_EVENT, "get bus center callback failed");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_GET_CLIENT_IDENTITY_FAILED;
}
for (int i = 0; i < num; i++) {
svc[i].handle = svcId[i].handle;
@ -85,7 +85,7 @@ int32_t ClientOnJoinLNNResult(const char *pkgName, void *addr, uint32_t addrType
SvcIdentity svc = {0};
if (GetSvcIdentityByPkgName(pkgName, &svc) != SOFTBUS_OK) {
LNN_LOGE(LNN_EVENT, "get svc failed");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_GET_SERVICE_IDENTITY_FAILED;
}
MessageOption option;
MessageOptionInit(&option);
@ -93,7 +93,7 @@ int32_t ClientOnJoinLNNResult(const char *pkgName, void *addr, uint32_t addrType
int32_t ans = SendRequest(svc, CLIENT_ON_JOIN_RESULT, &io, NULL, option, NULL);
if (ans != SOFTBUS_OK) {
LNN_LOGE(LNN_EVENT, "SendRequest failed, ans=%{public}d", ans);
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_SEND_REQUEST_FAILED;
}
return SOFTBUS_OK;
}
@ -113,7 +113,7 @@ int32_t ClientOnLeaveLNNResult(const char *pkgName, const char *networkId, int r
SvcIdentity svc = {0};
if (GetSvcIdentityByPkgName(pkgName, &svc) != SOFTBUS_OK) {
LNN_LOGE(LNN_EVENT, "get svc failed");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_GET_SERVICE_IDENTITY_FAILED;
}
MessageOption option;
MessageOptionInit(&option);
@ -121,7 +121,7 @@ int32_t ClientOnLeaveLNNResult(const char *pkgName, const char *networkId, int r
int32_t ans = SendRequest(svc, CLIENT_ON_LEAVE_RESULT, &io, NULL, option, NULL);
if (ans != SOFTBUS_OK) {
LNN_LOGE(LNN_EVENT, "SendRequest failed, ans=%{public}d", ans);
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_SEND_REQUEST_FAILED;
}
return SOFTBUS_OK;
}
@ -143,11 +143,11 @@ int32_t ClinetOnNodeOnlineStateChanged(bool isOnline, void *info, uint32_t infoT
int i;
if (SERVER_GetClientInfoNodeNum(&num) != SOFTBUS_OK) {
LNN_LOGE(LNN_EVENT, "get svc num failed");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_GET_SERVICE_NUM_FAILED;
}
if (num == 0) {
LNN_LOGE(LNN_EVENT, "svc num is 0");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_GET_SERVICE_NUM_ZERO;
}
SvcIdentity *svc = (SvcIdentity *)SoftBusCalloc(sizeof(SvcIdentity) * num);
if (svc == NULL) {
@ -157,7 +157,7 @@ int32_t ClinetOnNodeOnlineStateChanged(bool isOnline, void *info, uint32_t infoT
if (GetAllClientIdentity(svc, num) != SOFTBUS_OK) {
LNN_LOGE(LNN_EVENT, "get svc num failed");
SoftBusFree(svc);
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_GET_CLIENT_IDENTITY_FAILED;
}
MessageOption option;
MessageOptionInit(&option);
@ -167,7 +167,7 @@ int32_t ClinetOnNodeOnlineStateChanged(bool isOnline, void *info, uint32_t infoT
if (ans != SOFTBUS_OK) {
LNN_LOGE(LNN_EVENT, "SendRequest failed, ans=%{public}d", ans);
SoftBusFree(svc);
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_SEND_REQUEST_FAILED;
}
}
SoftBusFree(svc);
@ -191,11 +191,11 @@ int32_t ClinetOnNodeBasicInfoChanged(void *info, uint32_t infoTypeLen, int32_t t
int i;
if (SERVER_GetClientInfoNodeNum(&num) != SOFTBUS_OK) {
LNN_LOGE(LNN_EVENT, "get svc num failed");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_GET_SERVICE_NUM_FAILED;
}
if (num == 0) {
LNN_LOGE(LNN_EVENT, "svc num NULL");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_GET_SERVICE_NUM_ZERO;
}
SvcIdentity *svc = (SvcIdentity *)SoftBusCalloc(sizeof(SvcIdentity) * num);
if (svc == NULL) {
@ -205,7 +205,7 @@ int32_t ClinetOnNodeBasicInfoChanged(void *info, uint32_t infoTypeLen, int32_t t
if (GetAllClientIdentity(svc, num) != SOFTBUS_OK) {
LNN_LOGE(LNN_EVENT, "get svc num failed.");
SoftBusFree(svc);
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_GET_CLIENT_IDENTITY_FAILED;
}
MessageOption option;
MessageOptionInit(&option);
@ -215,7 +215,7 @@ int32_t ClinetOnNodeBasicInfoChanged(void *info, uint32_t infoTypeLen, int32_t t
if (ans != SOFTBUS_OK) {
LNN_LOGE(LNN_EVENT, "SendRequest failed, ans=%{public}d", ans);
SoftBusFree(svc);
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_SEND_REQUEST_FAILED;
}
}
SoftBusFree(svc);
@ -240,7 +240,7 @@ int32_t ClientOnTimeSyncResult(const char *pkgName, int32_t pid, const void *inf
SvcIdentity svc = {0};
if (GetSvcIdentityByPkgName(pkgName, &svc) != SOFTBUS_OK) {
LNN_LOGE(LNN_EVENT, "get svc failed");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_GET_SERVICE_IDENTITY_FAILED;
}
MessageOption option;
MessageOptionInit(&option);
@ -248,7 +248,7 @@ int32_t ClientOnTimeSyncResult(const char *pkgName, int32_t pid, const void *inf
int32_t ans = SendRequest(svc, CLIENT_ON_TIME_SYNC_RESULT, &io, NULL, option, NULL);
if (ans != SOFTBUS_OK) {
LNN_LOGE(LNN_EVENT, "SendRequest failed, ans=%{public}d", ans);
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_SEND_REQUEST_FAILED;
}
return SOFTBUS_OK;
}
@ -270,7 +270,7 @@ int32_t ClientOnPublishLNNResult(const char *pkgName, int32_t pid, int32_t publi
SvcIdentity svc = {0};
if (GetSvcIdentityByPkgName(pkgName, &svc) != SOFTBUS_OK) {
LNN_LOGE(LNN_EVENT, "get svc failed");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_GET_SERVICE_IDENTITY_FAILED;
}
MessageOption option;
MessageOptionInit(&option);
@ -278,7 +278,7 @@ int32_t ClientOnPublishLNNResult(const char *pkgName, int32_t pid, int32_t publi
int32_t ans = SendRequest(svc, CLIENT_ON_PUBLISH_LNN_RESULT, &io, NULL, option, NULL);
if (ans != SOFTBUS_OK) {
LNN_LOGE(LNN_EVENT, "SendRequest failed, ans=%{public}d", ans);
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_SEND_REQUEST_FAILED;
}
return SOFTBUS_OK;
}
@ -300,7 +300,7 @@ int32_t ClientOnRefreshLNNResult(const char *pkgName, int32_t pid, int32_t refre
SvcIdentity svc = {0};
if (GetSvcIdentityByPkgName(pkgName, &svc) != SOFTBUS_OK) {
LNN_LOGE(LNN_EVENT, "get svc failed");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_GET_SERVICE_IDENTITY_FAILED;
}
MessageOption option;
MessageOptionInit(&option);
@ -308,7 +308,7 @@ int32_t ClientOnRefreshLNNResult(const char *pkgName, int32_t pid, int32_t refre
int32_t ans = SendRequest(svc, CLIENT_ON_REFRESH_LNN_RESULT, &io, NULL, option, NULL);
if (ans != SOFTBUS_OK) {
LNN_LOGE(LNN_EVENT, "SendRequest failed, ans=%{public}d", ans);
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_SEND_REQUEST_FAILED;
}
return SOFTBUS_OK;
}
@ -330,7 +330,7 @@ int32_t ClientOnRefreshDeviceFound(const char *pkgName, int32_t pid, const void
SvcIdentity svc = {0};
if (GetSvcIdentityByPkgName(pkgName, &svc) != SOFTBUS_OK) {
LNN_LOGE(LNN_EVENT, "get svc failed");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_GET_SERVICE_IDENTITY_FAILED;
}
MessageOption option;
MessageOptionInit(&option);
@ -338,7 +338,7 @@ int32_t ClientOnRefreshDeviceFound(const char *pkgName, int32_t pid, const void
int32_t ans = SendRequest(svc, CLIENT_ON_REFRESH_DEVICE_FOUND, &io, NULL, option, NULL);
if (ans != SOFTBUS_OK) {
LNN_LOGE(LNN_EVENT, "SendRequest failed, ans=%{public}d", ans);
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_SEND_REQUEST_FAILED;
}
return SOFTBUS_OK;
}

View File

@ -116,7 +116,7 @@ static bool IsRepeatJoinLNNRequest(const char *pkgName, const ConnectionAddr *ad
if (list == NULL) {
LNN_LOGE(LNN_EVENT, "request info list empty");
return SOFTBUS_ERR;
return SOFTBUS_LIST_EMPTY;
}
LIST_FOR_EACH_ENTRY(info, &list->list, JoinLnnRequestInfo, node) {
if (strncmp(pkgName, info->pkgName, strlen(pkgName)) != 0) {
@ -390,7 +390,7 @@ int32_t LnnIpcNotifyJoinResult(void *addr, uint32_t addrTypeLen, const char *net
SoftBusList *list = g_lnnRequestInfo.joinLNNRequestInfo;
if (list == NULL) {
LNN_LOGE(LNN_EVENT, "request info is null");
return SOFTBUS_ERR;
return SOFTBUS_LIST_EMPTY;
}
if (SoftBusMutexLock(&g_lnnRequestInfo.lock) != 0) {
LNN_LOGE(LNN_EVENT, "get lock fail");
@ -416,7 +416,7 @@ int32_t LnnIpcNotifyLeaveResult(const char *networkId, int32_t retCode)
SoftBusList *list = g_lnnRequestInfo.leaveLNNRequestInfo;
if (list == NULL) {
LNN_LOGE(LNN_EVENT, "request info is null");
return SOFTBUS_ERR;
return SOFTBUS_LIST_EMPTY;
}
if (SoftBusMutexLock(&g_lnnRequestInfo.lock) != 0) {
LNN_LOGE(LNN_EVENT, "get lock fail");

View File

@ -37,12 +37,12 @@ int32_t ClientOnJoinLNNResult(PkgNameAndPidInfo *info, void *addr, uint32_t addr
{
if (info == nullptr) {
LNN_LOGE(LNN_EVENT, "pkgName is null");
return SOFTBUS_ERR;
return SOFTBUS_INVALID_PARAM;
}
sptr<BusCenterClientProxy> clientProxy = GetClientProxy(info->pkgName, info->pid);
if (clientProxy == nullptr) {
LNN_LOGE(LNN_EVENT, "bus center client proxy is nullptr");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_GET_CLIENT_PROXY_NULL;
}
return clientProxy->OnJoinLNNResult(addr, addrTypeLen, networkId, retCode);
}
@ -57,7 +57,7 @@ int32_t ClientOnLeaveLNNResult(
sptr<BusCenterClientProxy> clientProxy = GetClientProxy(pkgName, pid);
if (clientProxy == nullptr) {
LNN_LOGE(LNN_EVENT, "bus center client proxy is nullptr");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_GET_CLIENT_PROXY_NULL;
}
return clientProxy->OnLeaveLNNResult(networkId, retCode);
}
@ -138,7 +138,7 @@ int32_t ClientNotifyHichainProofException(
sptr<BusCenterClientProxy> clientProxy = new (std::nothrow) BusCenterClientProxy(proxy.second);
if (clientProxy == nullptr) {
LNN_LOGE(LNN_EVENT, "bus center client proxy is nullptr");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_GET_CLIENT_PROXY_NULL;
}
clientProxy->OnHichainProofException(proxy.first.c_str(), proofInfo, proofLen, deviceTypeId, errCode);
}
@ -155,7 +155,7 @@ int32_t ClientOnTimeSyncResult(const char *pkgName, int32_t pid, const void *inf
sptr<BusCenterClientProxy> clientProxy = GetClientProxy(pkgName, pid);
if (clientProxy == nullptr) {
LNN_LOGE(LNN_EVENT, "bus center client proxy is nullptr");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_GET_CLIENT_PROXY_NULL;
}
return clientProxy->OnTimeSyncResult(info, infoTypeLen, retCode);
}
@ -170,7 +170,7 @@ int32_t ClientOnPublishLNNResult(const char *pkgName, int32_t pid, int32_t publi
sptr<BusCenterClientProxy> clientProxy = GetClientProxy(pkgName, pid);
if (clientProxy == nullptr) {
LNN_LOGE(LNN_EVENT, "bus center client proxy is nullptr");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_GET_CLIENT_PROXY_NULL;
}
clientProxy->OnPublishLNNResult(publishId, reason);
return SOFTBUS_OK;
@ -186,7 +186,7 @@ int32_t ClientOnRefreshLNNResult(const char *pkgName, int32_t pid, int32_t refre
sptr<BusCenterClientProxy> clientProxy = GetClientProxy(pkgName, pid);
if (clientProxy == nullptr) {
LNN_LOGE(LNN_EVENT, "bus center client proxy is nullptr");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_GET_CLIENT_PROXY_NULL;
}
clientProxy->OnRefreshLNNResult(refreshId, reason);
return SOFTBUS_OK;
@ -202,7 +202,7 @@ int32_t ClientOnRefreshDeviceFound(
sptr<BusCenterClientProxy> clientProxy = GetClientProxy(pkgName, pid);
if (clientProxy == nullptr) {
LNN_LOGE(LNN_EVENT, "bus center client proxy is nullptr");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_GET_CLIENT_PROXY_NULL;
}
clientProxy->OnRefreshDeviceFound(device, deviceLen);
return SOFTBUS_OK;
@ -224,7 +224,7 @@ int32_t ClientOnDataLevelChanged(const char *pkgName, int32_t pid, const char *n
sptr<BusCenterClientProxy> clientProxy = GetClientProxy(pkgName, pid);
if (clientProxy == nullptr) {
LNN_LOGE(LNN_EVENT, "bus center client proxy is nullptr");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_GET_CLIENT_PROXY_NULL;
}
clientProxy->OnDataLevelChanged(networkId, dataLevelInfo);
return SOFTBUS_OK;

View File

@ -58,38 +58,38 @@ int32_t BusCenterClientProxy::OnJoinLNNResult(void *addr, uint32_t addrTypeLen,
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
LNN_LOGE(LNN_EVENT, "remote is nullptr");
return SOFTBUS_INVALID_PARAM;
return SOFTBUS_NETWORK_REMOTE_NULL;
}
if (addr == nullptr || (retCode == 0 && networkId == nullptr)) {
LNN_LOGE(LNN_EVENT, "invalid parameters");
return SOFTBUS_ERR;
return SOFTBUS_INVALID_PARAM;
}
MessageParcel data;
if (!data.WriteInterfaceToken(GetDescriptor())) {
LNN_LOGE(LNN_EVENT, "write InterfaceToken failed!");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_WRITETOKEN_FAILED;
}
if (!data.WriteUint32(addrTypeLen)) {
LNN_LOGE(LNN_EVENT, "write addr type length failed");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_WRITEINT32_FAILED;
}
if (!data.WriteRawData(addr, addrTypeLen)) {
LNN_LOGE(LNN_EVENT, "write addr failed");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_WRITERAWDATA_FAILED;
}
if (!data.WriteInt32(retCode)) {
LNN_LOGE(LNN_EVENT, "write retCode failed");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_WRITEINT32_FAILED;
}
if (retCode == 0 && !data.WriteCString(networkId)) {
LNN_LOGE(LNN_EVENT, "write networkId failed");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_WRITECSTRING_FAILED;
}
MessageParcel reply;
MessageOption option = { MessageOption::TF_ASYNC };
if (remote->SendRequest(CLIENT_ON_JOIN_RESULT, data, reply, option) != 0) {
LNN_LOGE(LNN_EVENT, "send request failed");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_SEND_REQUEST_FAILED;
}
return SOFTBUS_OK;
}
@ -100,45 +100,45 @@ int32_t BusCenterClientProxy::OnJoinMetaNodeResult(void *addr, uint32_t addrType
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr || metaInfo == nullptr) {
LNN_LOGE(LNN_EVENT, "remote is nullptr");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_REMOTE_NULL;
}
MessageParcel data;
if (!data.WriteInterfaceToken(GetDescriptor())) {
LNN_LOGE(LNN_EVENT, "write InterfaceToken failed!");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_WRITETOKEN_FAILED;
}
if (addr != nullptr) {
if (!data.WriteUint32(addrTypeLen)) {
LNN_LOGE(LNN_EVENT, "write addr type length failed");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_WRITEINT32_FAILED;
}
if (!data.WriteRawData(addr, addrTypeLen)) {
LNN_LOGE(LNN_EVENT, "write addr failed");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_WRITERAWDATA_FAILED;
}
} else {
if (!data.WriteUint32(0)) {
LNN_LOGE(LNN_EVENT, "write addr type length failed");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_WRITEINT32_FAILED;
}
}
if (!data.WriteUint32(infoLen)) {
LNN_LOGE(LNN_EVENT, "write infoLen failed");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_WRITEINT32_FAILED;
}
if (!data.WriteRawData(metaInfo, infoLen)) {
LNN_LOGE(LNN_EVENT, "write metaInfo failed");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_WRITERAWDATA_FAILED;
}
if (!data.WriteInt32(retCode)) {
LNN_LOGE(LNN_EVENT, "write retCode failed");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_WRITEINT32_FAILED;
}
MessageParcel reply;
MessageOption option = { MessageOption::TF_ASYNC };
if (remote->SendRequest(CLIENT_ON_JOIN_METANODE_RESULT, data, reply, option) != 0) {
LNN_LOGE(LNN_EVENT, "OnJoinMetaNodeResult send request failed");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_SEND_REQUEST_FAILED;
}
return SOFTBUS_OK;
}
@ -148,7 +148,7 @@ int32_t BusCenterClientProxy::OnLeaveLNNResult(const char *networkId, int retCod
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
LNN_LOGE(LNN_EVENT, "remote is nullptr");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_REMOTE_NULL;
}
if (networkId == nullptr) {
LNN_LOGE(LNN_EVENT, "invalid parameters");
@ -157,21 +157,21 @@ int32_t BusCenterClientProxy::OnLeaveLNNResult(const char *networkId, int retCod
MessageParcel data;
if (!data.WriteInterfaceToken(GetDescriptor())) {
LNN_LOGE(LNN_EVENT, "write InterfaceToken failed!");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_WRITETOKEN_FAILED;
}
if (!data.WriteCString(networkId)) {
LNN_LOGE(LNN_EVENT, "write networkId failed");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_WRITECSTRING_FAILED;
}
if (!data.WriteInt32(retCode)) {
LNN_LOGE(LNN_EVENT, "write retCode failed");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_WRITEINT32_FAILED;
}
MessageParcel reply;
MessageOption option = { MessageOption::TF_ASYNC };
if (remote->SendRequest(CLIENT_ON_LEAVE_RESULT, data, reply, option) != 0) {
LNN_LOGE(LNN_EVENT, "send request fail");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_SEND_REQUEST_FAILED;
}
return SOFTBUS_OK;
}
@ -181,7 +181,7 @@ int32_t BusCenterClientProxy::OnLeaveMetaNodeResult(const char *networkId, int r
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
LNN_LOGE(LNN_EVENT, "remote is nullptr");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_REMOTE_NULL;
}
if (networkId == nullptr) {
LNN_LOGE(LNN_EVENT, "invalid parameters");
@ -190,21 +190,21 @@ int32_t BusCenterClientProxy::OnLeaveMetaNodeResult(const char *networkId, int r
MessageParcel data;
if (!data.WriteInterfaceToken(GetDescriptor())) {
LNN_LOGE(LNN_EVENT, "write InterfaceToken failed!");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_WRITETOKEN_FAILED;
}
if (!data.WriteCString(networkId)) {
LNN_LOGE(LNN_EVENT, "write networkId failed");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_WRITECSTRING_FAILED;
}
if (!data.WriteInt32(retCode)) {
LNN_LOGE(LNN_EVENT, "write retCode failed");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_WRITEINT32_FAILED;
}
MessageParcel reply;
MessageOption option = { MessageOption::TF_ASYNC };
if (remote->SendRequest(CLIENT_ON_LEAVE_METANODE_RESULT, data, reply, option) != 0) {
LNN_LOGE(LNN_EVENT, "send request fail");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_SEND_REQUEST_FAILED;
}
return SOFTBUS_OK;
}
@ -215,7 +215,7 @@ int32_t BusCenterClientProxy::OnNodeOnlineStateChanged(const char *pkgName, bool
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
LNN_LOGE(LNN_EVENT, "remote is nullptr");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_REMOTE_NULL;
}
if (pkgName == nullptr) {
LNN_LOGE(LNN_EVENT, "pkgName is nullptr");
@ -228,35 +228,35 @@ int32_t BusCenterClientProxy::OnNodeOnlineStateChanged(const char *pkgName, bool
MessageParcel data;
if (!data.WriteInterfaceToken(GetDescriptor())) {
LNN_LOGE(LNN_EVENT, "write InterfaceToken failed!");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_WRITETOKEN_FAILED;
}
if (!data.WriteCString(pkgName)) {
LNN_LOGE(LNN_EVENT, "write pkgName failed");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_WRITECSTRING_FAILED;
}
if (!data.WriteBool(isOnline)) {
LNN_LOGE(LNN_EVENT, "write online state failed");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_WRITEBOOL_FAILED;
}
if (!data.WriteUint32(infoTypeLen)) {
LNN_LOGE(LNN_EVENT, "write info type length failed");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_WRITEINT32_FAILED;
}
if (!data.WriteRawData(info, infoTypeLen)) {
LNN_LOGE(LNN_EVENT, "write node info failed");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_WRITERAWDATA_FAILED;
}
MessageParcel reply;
MessageOption option;
int ret = remote->SendRequest(CLIENT_ON_NODE_ONLINE_STATE_CHANGED, data, reply, option);
if (ret != 0) {
LNN_LOGE(LNN_EVENT, "send request failed, ret=%{public}d", ret);
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_SEND_REQUEST_FAILED;
}
int32_t serverRet;
if (!reply.ReadInt32(serverRet)) {
LNN_LOGE(LNN_EVENT, "read serverRet failed");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_READINT32_FAILED;
}
return serverRet;
}
@ -267,7 +267,7 @@ int32_t BusCenterClientProxy::OnNodeBasicInfoChanged(const char *pkgName, void *
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
LNN_LOGE(LNN_EVENT, "remote is nullptr");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_REMOTE_NULL;
}
if (pkgName == nullptr) {
LNN_LOGE(LNN_EVENT, "pkgName is nullptr");
@ -280,35 +280,35 @@ int32_t BusCenterClientProxy::OnNodeBasicInfoChanged(const char *pkgName, void *
MessageParcel data;
if (!data.WriteInterfaceToken(GetDescriptor())) {
LNN_LOGE(LNN_EVENT, "write InterfaceToken failed!");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_WRITETOKEN_FAILED;
}
if (!data.WriteCString(pkgName)) {
LNN_LOGE(LNN_EVENT, "write pkgName failed");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_WRITECSTRING_FAILED;
}
if (!data.WriteInt32(type)) {
LNN_LOGE(LNN_EVENT, "write type failed");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_WRITEINT32_FAILED;
}
if (!data.WriteUint32(infoTypeLen)) {
LNN_LOGE(LNN_EVENT, "write info type length failed");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_WRITEINT32_FAILED;
}
if (!data.WriteRawData(info, infoTypeLen)) {
LNN_LOGE(LNN_EVENT, "write node info failed");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_WRITERAWDATA_FAILED;
}
MessageParcel reply;
MessageOption option;
int ret = remote->SendRequest(CLIENT_ON_NODE_BASIC_INFO_CHANGED, data, reply, option);
if (ret != 0) {
LNN_LOGE(LNN_EVENT, "send request failed, ret=%{public}d", ret);
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_SEND_REQUEST_FAILED;
}
int32_t serverRet;
if (!reply.ReadInt32(serverRet)) {
LNN_LOGE(LNN_EVENT, "read serverRet failed");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_READINT32_FAILED;
}
return SOFTBUS_OK;
}
@ -366,7 +366,7 @@ int32_t BusCenterClientProxy::OnLocalNetworkIdChanged(const char *pkgName)
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
LNN_LOGE(LNN_EVENT, "remote is nullptr");
return SOFTBUS_IPC_ERR;
return SOFTBUS_NETWORK_REMOTE_NULL;
}
if (pkgName == nullptr) {
LNN_LOGE(LNN_EVENT, "pkgName is nullptr");
@ -402,7 +402,7 @@ int32_t BusCenterClientProxy::OnNodeDeviceTrustedChange(const char *pkgName, int
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
LNN_LOGE(LNN_EVENT, "remote is nullptr");
return SOFTBUS_IPC_ERR;
return SOFTBUS_NETWORK_REMOTE_NULL;
}
if (pkgName == nullptr|| msg == nullptr) {
LNN_LOGE(LNN_EVENT, "invalid parameters");
@ -489,7 +489,7 @@ int32_t BusCenterClientProxy::OnTimeSyncResult(const void *info, uint32_t infoTy
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
LNN_LOGE(LNN_EVENT, "remote is nullptr");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_REMOTE_NULL;
}
if (info == nullptr) {
LNN_LOGE(LNN_EVENT, "invalid parameters");
@ -498,31 +498,31 @@ int32_t BusCenterClientProxy::OnTimeSyncResult(const void *info, uint32_t infoTy
MessageParcel data;
if (!data.WriteInterfaceToken(GetDescriptor())) {
LNN_LOGE(LNN_EVENT, "write InterfaceToken failed!");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_WRITETOKEN_FAILED;
}
if (!data.WriteUint32(infoTypeLen)) {
LNN_LOGE(LNN_EVENT, "write info length failed");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_WRITEINT32_FAILED;
}
if (!data.WriteRawData(info, infoTypeLen)) {
LNN_LOGE(LNN_EVENT, "write info failed");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_WRITERAWDATA_FAILED;
}
if (!data.WriteInt32(retCode)) {
LNN_LOGE(LNN_EVENT, "write retCode failed");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_WRITEINT32_FAILED;
}
MessageParcel reply;
MessageOption option;
int ret = remote->SendRequest(CLIENT_ON_TIME_SYNC_RESULT, data, reply, option);
if (ret != 0) {
LNN_LOGE(LNN_EVENT, "send request failed, ret=%{public}d", ret);
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_SEND_REQUEST_FAILED;
}
int32_t serverRet;
if (!reply.ReadInt32(serverRet)) {
LNN_LOGE(LNN_EVENT, "read serverRet failed");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_READINT32_FAILED;
}
return SOFTBUS_OK;
}

View File

@ -261,12 +261,12 @@ int32_t LnnIpcRegDataLevelChangeCb(const char *pkgName, int32_t callingPid)
DataLevelChangeReqInfo *info = new (std::nothrow) DataLevelChangeReqInfo();
if (info == nullptr) {
COMM_LOGE(COMM_SVC, "DataLevelChangeReqInfo object is nullptr");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_REG_CB_FAILED;
}
if (strcpy_s(info->pkgName, PKG_NAME_SIZE_MAX, pkgName) != EOK) {
LNN_LOGE(LNN_EVENT, "copy pkgName fail");
delete info;
return SOFTBUS_MEM_ERR;
return SOFTBUS_STRCPY_ERR;
}
info->pid = callingPid;
g_dataLevelChangeRequestInfo.push_back(info);
@ -406,7 +406,7 @@ int32_t LnnIpcStopRefreshLNN(const char *pkgName, int32_t callingPid, int32_t su
if (IsRepeatRefreshLnnRequest(pkgName, callingPid, subscribeId) &&
DeleteRefreshLnnInfo(pkgName, callingPid, subscribeId) != SOFTBUS_OK) {
LNN_LOGE(LNN_EVENT, "stop refresh lnn, clean info fail");
return SOFTBUS_ERR;
return SOFTBUS_NETWORK_STOP_REFRESH_LNN_FAILED;
}
return LnnStopDiscDevice(pkgName, subscribeId, false);
}

View File

@ -82,8 +82,17 @@ CONN_ASSIGNER(Errcode, StaChannel, staChannel)
CONN_ASSIGNER(Errcode, ApChannel, apChannel)
CONN_ASSIGNER(String, PeerDevVer, peerDevVer)
CONN_ASSIGNER(Errcode, RemoteScreenStatus, remoteScreenStatus)
CONN_ASSIGNER(Errcode, BusinessType, businessType)
CONN_ASSIGNER(Int32, BusinessId, businessId)
CONN_ASSIGNER(Errcode, Timeout, timeout)
CONN_ASSIGNER(Errcode, FastestConnectEnable, fastestConnectEnable)
CONN_ASSIGNER(Errcode, CoapDataChannel, coapDataChannel)
CONN_ASSIGNER(Errcode, EnableWideBandwidth, enableWideBandwidth)
CONN_ASSIGNER(Errcode, P2pRole, p2pRole)
CONN_ASSIGNER(Errcode, NeedHmlConnect, needHmlConnect)
CONN_ASSIGNER(String, BusinessTag, businessTag)
#define CONN_ASSIGNER_SIZE 48 // Size of g_connAssigners
#define CONN_ASSIGNER_SIZE 57 // Size of g_connAssigners
static HiSysEventParamAssigner g_connAssigners[] = {
{ "STAGE_RES", HISYSEVENT_INT32, ConnAssignerResult },
{ "ERROR_CODE", HISYSEVENT_INT32, ConnAssignerErrcode },
@ -125,14 +134,23 @@ static HiSysEventParamAssigner g_connAssigners[] = {
{ "NEGOTIATE_TIME", HISYSEVENT_UINT64, ConnAssignerNegotiateTime },
{ "LINK_TIME", HISYSEVENT_UINT64, ConnAssignerLinkTime },
{ "OS_TYPE", HISYSEVENT_INT32, ConnAssignerOsType },
{ "LOCAL_DEVICE_TYPE", HISYSEVENT_STRING, ConnAssignerLocalDeviceType },
{ "REMOTE_DEVICE_TYPE", HISYSEVENT_STRING, ConnAssignerRemoteDeviceType },
{ "LOCAL_DEV_TYPE", HISYSEVENT_STRING, ConnAssignerLocalDeviceType },
{ "PEER_DEV_TYPE", HISYSEVENT_STRING, ConnAssignerRemoteDeviceType },
{ "P2P_CHANNEL", HISYSEVENT_INT32, ConnAssignerP2pChannel },
{ "HML_CHANNEL", HISYSEVENT_INT32, ConnAssignerHmlChannel },
{ "STA_CHANNEL", HISYSEVENT_INT32, ConnAssignerStaChannel },
{ "AP_CHANNEL", HISYSEVENT_INT32, ConnAssignerApChannel },
{ "PEER_DEV_VER", HISYSEVENT_STRING, ConnAssignerPeerDevVer },
{ "REMOTE_SCREEN_STATUS", HISYSEVENT_INT32, ConnAssignerRemoteScreenStatus},
{ "BUSINESS_TYPE", HISYSEVENT_INT32, ConnAssignerBusinessType },
{ "BUSINESS_ID", HISYSEVENT_INT32, ConnAssignerBusinessId },
{ "TIME_OUT", HISYSEVENT_INT32, ConnAssignerTimeout },
{ "FASTEST_CONNECT_ENABLE", HISYSEVENT_INT32, ConnAssignerFastestConnectEnable},
{ "COAP_DATA_CHANNEL", HISYSEVENT_INT32, ConnAssignerCoapDataChannel },
{ "ENABLE_WIDE_BANDWIDTH", HISYSEVENT_INT32, ConnAssignerEnableWideBandwidth },
{ "P2P_ROLE", HISYSEVENT_INT32, ConnAssignerP2pRole },
{ "NEED_HML_CONNECT", HISYSEVENT_INT32, ConnAssignerNeedHmlConnect },
{ "BUSINESS_TAG", HISYSEVENT_STRING, ConnAssignerBusinessTag },
// Modification Note: remember updating CONN_ASSIGNER_SIZE
};

View File

@ -34,6 +34,7 @@ typedef enum {
EVENT_SCENE_SOCKET_CONNECT = 7,
EVENT_SCENE_SOCKET_SHUTDOWN = 8,
EVENT_SCENE_SOCKET_CLOSE = 9,
EVENT_SCENE_LEGACY_CONNECT = 10,
} ConnEventScene;
typedef enum {
@ -112,6 +113,15 @@ typedef struct {
int32_t apChannel; // HOTSPOT_CHAN
const char *peerDevVer; // REMOTE_OS_VERSION
int32_t remoteScreenStatus; // REMOTE_SCREEN_STATUS
int32_t businessType; // BUSINESS_TYPE
int32_t businessId; // BUSINESS_ID
int32_t timeout; // TIME_OUT
int32_t fastestConnectEnable; // FASTEST_CONNECT_ENABLE
int32_t coapDataChannel; // COAP_DATA_CHANNEL
int32_t enableWideBandwidth; // ENABLE_WIDE_BANDWIDTH
int32_t p2pRole; // P2P_ROLE
int32_t needHmlConnect; // NEED_HML_CONNECT
const char *businessTag; // BUSINESS_TAG
} ConnEventExtra;
typedef enum {

View File

@ -39,6 +39,10 @@ typedef enum {
EVENT_SCENE_TRANS_PROXY_RESET_PEER = 12,
EVENT_SCENE_TRANS_CHANNEL_STATISTICS = 13,
EVENT_SCENE_TRANS_CHANNEL_INSTANT = 14,
EVENT_SCENE_TRANS_MESSAGE_PARSE = 15,
EVENT_SCENE_TRANS_RECEIVED_DATA = 16,
EVENT_SCENE_TRANS_SEND_DATA = 17,
EVENT_SCENE_CHANNEL_REQUEST = 18,
} TransEventScene;
typedef enum {

View File

@ -639,11 +639,19 @@ enum SoftBusErrNo {
SOFTBUS_CENTER_EVENT_INIT_FAILED,
SOFTBUS_NETWORK_GET_INVALID_DEVICE_INFO,
SOFTBUS_NETWORK_GET_UUID_FROM_FILE_FAILED,
SOFTBUS_NETWORK_GET_CLIENT_IDENTITY_FAILED,
SOFTBUS_NETWORK_WRITEBOOL_FAILED,
SOFTBUS_NETWORK_REG_CB_FAILED,
SOFTBUS_NETWORK_GET_SERVICE_IDENTITY_FAILED,
SOFTBUS_NETWORK_GET_SERVICE_NUM_FAILED,
SOFTBUS_NETWORK_GET_SERVICE_NUM_ZERO,
SOFTBUS_NETWORK_GET_CLIENT_PROXY_NULL,
SOFTBUS_NETWORK_STOP_REFRESH_LNN_FAILED,
SOFTBUS_NETWORK_SEND_MSG_TO_MLPS_FAILED,
SOFTBUS_NETWORK_REGISTER_MLPS_LISTENER_FAILED,
SOFTBUS_NETWORK_REGISTER_SERVICE_FAILED,
SOFTBUS_NETWORK_UNREGISTER_SERVICE_FAILED,
/* errno begin: -((203 << 21) | (4 << 16) | (1 << 12) | 0x0FFF) */
SOFTBUS_LANE_ERR_BASE = SOFTBUS_SUB_ERRNO(LNN_SUB_MODULE_CODE, LNN_LANE_MODULE_CODE),
SOFTBUS_LANE_SELECT_FAIL,

View File

@ -71,9 +71,9 @@ HWTEST_F(ClientProxyTest, OnJoinLNNResultTest_01, TestSize.Level1)
char *addr = const_cast<char *>(TEST_ADDR);
void *addrInput = reinterpret_cast<void *>(addr);
int32_t ret = clientProxy->OnJoinLNNResult(nullptr, TEST_ADDR_TYPE_LEN, TEST_NETWORK_ID, TEST_RET_CODE);
EXPECT_TRUE(ret == SOFTBUS_ERR);
EXPECT_NE(ret, SOFTBUS_OK);
ret = clientProxy->OnJoinLNNResult(addrInput, TEST_ADDR_TYPE_LEN, nullptr, TEST_RET_CODE);
EXPECT_TRUE(ret == SOFTBUS_ERR);
EXPECT_NE(ret, SOFTBUS_OK);
ret = clientProxy->OnJoinLNNResult(addrInput, TEST_ADDR_TYPE_LEN, TEST_NETWORK_ID, TEST_RET_CODE);
EXPECT_TRUE(ret == SOFTBUS_OK);
}

View File

@ -51,6 +51,11 @@ static void MatchConnEventNameTypeExtraStrParam(const HiSysEventParam *params, i
EXPECT_STREQ(params[index].v.s, extraParam);
}
static void MatchNotConnEventNameExtraStrParam(const HiSysEventParam *params, int32_t index, const char * extraParam)
{
EXPECT_NE(params[index].name, g_connAssigners[index].name);
}
static void MatchConnEventNameTypeExtraStrParamAnony(const HiSysEventParam *params, int32_t index,
const char * extraParam)
{
@ -66,14 +71,23 @@ static void MatchConnEventNameTypeExtraStrParamAnony(const HiSysEventParam *para
static int32_t MatchConnEventNameTypeExtraForAddMsg(const HiSysEventParam *params, int32_t index, ConnEventExtra extra)
{
MatchConnEventNameTypeExtraInt32Param(params, ++index, extra.osType);
MatchConnEventNameTypeExtraStrParam(params, ++index, extra.localDeviceType);
MatchConnEventNameTypeExtraStrParam(params, ++index, extra.remoteDeviceType);
MatchNotConnEventNameExtraStrParam(params, ++index, extra.localDeviceType);
MatchNotConnEventNameExtraStrParam(params, ++index, extra.remoteDeviceType);
MatchConnEventNameTypeExtraInt32Param(params, ++index, extra.p2pChannel);
MatchConnEventNameTypeExtraInt32Param(params, ++index, extra.hmlChannel);
MatchConnEventNameTypeExtraInt32Param(params, ++index, extra.staChannel);
MatchConnEventNameTypeExtraInt32Param(params, ++index, extra.apChannel);
MatchConnEventNameTypeExtraStrParam(params, ++index, extra.peerDevVer);
MatchConnEventNameTypeExtraInt32Param(params, ++index, extra.remoteScreenStatus);
MatchConnEventNameTypeExtraInt32Param(params, ++index, extra.businessType);
MatchConnEventNameTypeExtraInt32Param(params, ++index, extra.businessId);
MatchConnEventNameTypeExtraInt32Param(params, ++index, extra.timeout);
MatchConnEventNameTypeExtraInt32Param(params, ++index, extra.fastestConnectEnable);
MatchConnEventNameTypeExtraInt32Param(params, ++index, extra.coapDataChannel);
MatchConnEventNameTypeExtraInt32Param(params, ++index, extra.enableWideBandwidth);
MatchConnEventNameTypeExtraInt32Param(params, ++index, extra.p2pRole);
MatchConnEventNameTypeExtraInt32Param(params, ++index, extra.needHmlConnect);
MatchConnEventNameTypeExtraStrParam(params, ++index, extra.businessTag);
return ++index;
}

View File

@ -74,6 +74,15 @@ static ConnEventExtra g_validExtra = {
.apChannel = 22,
.peerDevVer = "peerDevVer",
.remoteScreenStatus = 1,
.businessType = 1,
.businessId = 1,
.timeout = 1,
.fastestConnectEnable = 1,
.coapDataChannel = 1,
.enableWideBandwidth = 1,
.p2pRole = 1,
.needHmlConnect = 1,
.businessTag = "test",
};
/**
@ -163,7 +172,7 @@ static ConnEventExtra g_invalidExtra = {
HWTEST_F(ConnEventTest, ConnEventTest003, TestSize.Level0)
{
constexpr int32_t TWO_VALID_EXTRA_SIZE = 2; // result, errcode is valid
constexpr int32_t VALID_EXTRA_SIZE = 15;
constexpr int32_t VALID_EXTRA_SIZE = 22;
HiSysEventMock mock;
EXPECT_CALL(mock,
@ -183,7 +192,7 @@ HWTEST_F(ConnEventTest, ConnEventTest004, TestSize.Level0)
{
ConnEventExtra emptyExtra = { 0 };
constexpr int32_t TWO_VALID_EXTRA_SIZE = 2; // result, errcode is valid
constexpr int32_t VALID_EXTRA_SIZE = 15;
constexpr int32_t VALID_EXTRA_SIZE = 22;
HiSysEventMock mock;
EXPECT_CALL(mock,