!8355 modify multi user feature change

Merge pull request !8355 from jiazhenyu/master
This commit is contained in:
openharmony_ci 2024-11-17 14:13:14 +00:00 committed by Gitee
commit 8e5ca2ff5a
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
28 changed files with 139 additions and 43 deletions

View File

@ -55,7 +55,7 @@ int32_t ServerCreateSessionServer(IpcIo *req, IpcIo *reply)
WriteInt32(reply, SOFTBUS_PERMISSION_DENIED);
return SOFTBUS_PERMISSION_DENIED;
}
int32_t ret = TransCreateSessionServer(pkgName, sessionName, callingUid, callingPid);
int32_t ret = TransCreateSessionServer(pkgName, sessionName, callingUid, callingPid, false);
(void)WriteInt32(reply, ret);
return ret;
}

View File

@ -31,7 +31,7 @@ public:
virtual int32_t SoftbusRegisterService(const char *clientPkgName, const sptr<IRemoteObject> &object) = 0;
virtual int32_t CreateSessionServer(const char *pkgName, const char *sessionName) = 0;
virtual int32_t CreateSessionServer(const char *pkgName, const char *sessionName, bool isNormalApp) = 0;
virtual int32_t RemoveSessionServer(const char *pkgName, const char *sessionName) = 0;
virtual int32_t OpenSession(const SessionParam *param, TransInfo *info) = 0;
virtual int32_t OpenAuthSession(const char *sessionName, const ConnectionAddr *addrInfo) = 0;

View File

@ -30,7 +30,7 @@ public:
int32_t SoftbusRegisterService(const char *clientPkgName, const sptr<IRemoteObject> &object) override;
int32_t CreateSessionServer(const char *pkgName, const char *sessionName) override;
int32_t CreateSessionServer(const char *pkgName, const char *sessionName, bool isNormalApp) override;
int32_t RemoveSessionServer(const char *pkgName, const char *sessionName) override;
int32_t OpenSession(const SessionParam *param, TransInfo *info) override;
int32_t OpenAuthSession(const char *sessionName, const ConnectionAddr *addrInfo) override;

View File

@ -88,11 +88,11 @@ int32_t SoftBusServer::SoftbusRegisterService(const char *clientPkgName, const s
return SOFTBUS_OK;
}
int32_t SoftBusServer::CreateSessionServer(const char *pkgName, const char *sessionName)
int32_t SoftBusServer::CreateSessionServer(const char *pkgName, const char *sessionName, bool isNormalApp)
{
pid_t callingUid = OHOS::IPCSkeleton::GetCallingUid();
pid_t callingPid = OHOS::IPCSkeleton::GetCallingPid();
return TransCreateSessionServer(pkgName, sessionName, (int32_t)callingUid, (int32_t)callingPid);
return TransCreateSessionServer(pkgName, sessionName, (int32_t)callingUid, (int32_t)callingPid, isNormalApp);
}
int32_t SoftBusServer::RemoveSessionServer(const char *pkgName, const char *sessionName)

View File

@ -381,9 +381,11 @@ static int32_t GetAppId(const std::string &bundleName, std::string &appId)
return SOFTBUS_OK;
}
static int32_t CheckNormalAppSessionName(const char *sessionName, pid_t callingUid, std::string &strName)
static int32_t CheckNormalAppSessionName(
const char *sessionName, pid_t callingUid, std::string &strName, bool *isNormalApp)
{
if (CheckCallingIsNormalApp(sessionName)) {
*isNormalApp = true;
std::string bundleName;
int32_t result = GetBundleName(callingUid, bundleName);
if (result != SOFTBUS_OK) {
@ -424,6 +426,7 @@ int32_t SoftBusServerStub::CreateSessionServerInner(MessageParcel &data, Message
{
COMM_LOGD(COMM_SVC, "enter");
int32_t retReply;
bool isNormalApp = false;
pid_t callingUid;
pid_t callingPid;
const char *pkgName = data.ReadCString();
@ -447,15 +450,14 @@ int32_t SoftBusServerStub::CreateSessionServerInner(MessageParcel &data, Message
retReply = SOFTBUS_PERMISSION_DENIED;
goto EXIT;
}
#ifdef SUPPORT_BUNDLENAME
if (CheckNormalAppSessionName(sessionName, callingUid, strName) != SOFTBUS_OK) {
if (CheckNormalAppSessionName(sessionName, callingUid, strName, &isNormalApp) != SOFTBUS_OK) {
retReply = SOFTBUS_PERMISSION_DENIED;
goto EXIT;
}
sessionName = strName.c_str();
#endif
retReply = CreateSessionServer(pkgName, sessionName);
retReply = CreateSessionServer(pkgName, sessionName, isNormalApp);
EXIT:
if (!reply.WriteInt32(retReply)) {
COMM_LOGE(COMM_SVC, "CreateSessionServerInner write reply failed!");

View File

@ -22,6 +22,15 @@
extern "C" {
#endif
typedef enum {
CALLER_TYPE_BEGIN,
CALLER_TYPE_SERVICE_ABILITY = CALLER_TYPE_BEGIN,
CALLER_TYPE_FEATURE_ABILITY,
CALLER_TYPE_PARTICAL_ABILITY,
CALLER_TYPE_DATA_ABILITY,
CALLER_TYPE_END,
} CallerType;
typedef struct {
ListNode node;
SoftBusSecType type;
@ -29,6 +38,7 @@ typedef struct {
char sessionName[SESSION_NAME_SIZE_MAX];
int32_t uid;
int32_t pid;
CallerType callerType;
} SessionServer;
int32_t TransSessionMgrInit(void);

View File

@ -23,7 +23,8 @@
extern "C" {
#endif
int32_t TransCreateSessionServer(const char *pkgName, const char *sessionName, int32_t uid, int32_t pid);
int32_t TransCreateSessionServer(
const char *pkgName, const char *sessionName, int32_t uid, int32_t pid, bool isNormalApp);
int32_t TransRemoveSessionServer(const char *pkgName, const char *sessionName);

View File

@ -389,6 +389,7 @@ void TransOnLinkDown(const char *networkId, const char *uuid, const char *udid,
}
int32_t routeType = (int32_t)GET_ROUTE_TYPE(type);
int32_t connType = (int32_t)GET_CONN_TYPE(type);
bool isUserSwitchEvent = (bool)((routeType >> 10) & 0xff);
char *anonyNetworkId = NULL;
Anonymize(networkId, &anonyNetworkId);
TRANS_LOGI(TRANS_CTRL,
@ -415,6 +416,9 @@ void TransOnLinkDown(const char *networkId, const char *uuid, const char *udid,
};
LIST_FOR_EACH_ENTRY_SAFE(pos, tmp, &sessionServerList, SessionServer, node) {
if (isUserSwitchEvent && pos->callerType != CALLER_TYPE_FEATURE_ABILITY) {
continue;
}
(void)TransServerOnChannelLinkDown(pos->pkgName, pos->pid, &info);
}

View File

@ -87,7 +87,8 @@ void TransServerDeathCallback(const char *pkgName, int32_t pid)
TransDelItemByPackageName(pkgName, pid);
}
int32_t TransCreateSessionServer(const char *pkgName, const char *sessionName, int32_t uid, int32_t pid)
int32_t TransCreateSessionServer(
const char *pkgName, const char *sessionName, int32_t uid, int32_t pid, bool isNormalApp)
{
if (!IsValidString(pkgName, PKG_NAME_SIZE_MAX - 1) ||
!IsValidString(sessionName, SESSION_NAME_SIZE_MAX - 1)) {
@ -113,6 +114,7 @@ int32_t TransCreateSessionServer(const char *pkgName, const char *sessionName, i
newNode->type = SEC_TYPE_CIPHERTEXT;
newNode->uid = uid;
newNode->pid = pid;
newNode->callerType = isNormalApp ? CALLER_TYPE_FEATURE_ABILITY : CALLER_TYPE_SERVICE_ABILITY;
int32_t ret = TransSessionServerAddItem(newNode);
TransEventExtra extra = {

View File

@ -1808,6 +1808,24 @@ static void TransNotifyOffLine(const LnnEventBasicInfo *info)
TransOnLinkDown(onlineStateInfo->networkId, onlineStateInfo->uuid, onlineStateInfo->udid, "", BT_BLE);
}
static void TransNotifyUserSwitch(const LnnEventBasicInfo *info)
{
TRANS_CHECK_AND_RETURN_LOGE(info != NULL, TRANS_CTRL, "invalid Lnn info");
const LnnMonitorHbStateChangedEvent *event = (const LnnMonitorHbStateChangedEvent *)info;
SoftBusUserSwitchState userSwitchState = (SoftBusUserSwitchState)event->status;
switch (userSwitchState) {
case SOFTBUS_USER_SWITCHED: {
TransOnLinkDown("", "", "", "", ROUTE_TYPE_ALL | 1 << 10);
break;
}
case SOFTBUS_USER_SWITCH_UNKNOWN:
default: {
TRANS_LOGE(TRANS_CTRL, "recv unknow user switch event, state=%{public}u", event->status);
break;
}
}
}
static int32_t TransProxyManagerInitInner(const IServerChannelCallBack *cb)
{
int32_t ret = TransProxySetCallBack(cb);
@ -1844,7 +1862,10 @@ int32_t TransProxyManagerInit(const IServerChannelCallBack *cb)
TRANS_CHECK_AND_RETURN_RET_LOGE(ret == SOFTBUS_OK, ret, TRANS_INIT, "register TransNotifyOffLine failed.");
ret = LnnRegisterEventHandler(LNN_EVENT_NODE_MIGRATE, TransWifiStateChange);
TRANS_CHECK_AND_RETURN_RET_LOGE(ret == SOFTBUS_OK, ret, TRANS_INIT, "TransWifiStateChange register fail");
TRANS_CHECK_AND_RETURN_RET_LOGE(ret == SOFTBUS_OK, ret, TRANS_INIT, "TransWifiStateChange register failed.");
ret = LnnRegisterEventHandler(LNN_EVENT_USER_SWITCHED, TransNotifyUserSwitch);
TRANS_CHECK_AND_RETURN_RET_LOGE(ret == SOFTBUS_OK, ret, TRANS_INIT, "register user switch event failed.");
TRANS_LOGI(TRANS_INIT, "proxy channel init ok");
return SOFTBUS_OK;

View File

@ -89,6 +89,7 @@ typedef enum {
SHUTDOWN_REASON_SERVICE_DIED, /**< Shutdown for death service */
SHUTDOWN_REASON_LNN_OFFLINE, /**< Shutdown for offline */
SHUTDOWN_REASON_LINK_DOWN, /**< Shutdown for link down */
SHUTDOWN_REASON_USER_SWICTH, /**< Shutdown for user switch */
} ShutdownReason;
/**

View File

@ -28,7 +28,7 @@ public:
int32_t SoftbusRegisterService(const char *clientPkgName, const sptr<IRemoteObject> &object) override;
int32_t CreateSessionServer(const char *pkgName, const char *sessionName) override;
int32_t CreateSessionServer(const char *pkgName, const char *sessionName, bool isNormalApp) override;
int32_t RemoveSessionServer(const char *pkgName, const char *sessionName) override;
int32_t OpenSession(const SessionParam *param, TransInfo *info) override;
int32_t NotifyAuthSuccess(int32_t channelId, int32_t channelType) override;

View File

@ -86,10 +86,11 @@ int32_t BusCenterServerProxy::SoftbusRegisterService(const char *clientPkgName,
return SOFTBUS_OK;
}
int32_t BusCenterServerProxy::CreateSessionServer(const char *pkgName, const char *sessionName)
int32_t BusCenterServerProxy::CreateSessionServer(const char *pkgName, const char *sessionName, bool isNormalApp)
{
(void)pkgName;
(void)sessionName;
(void)isNormalApp;
return SOFTBUS_OK;
}

View File

@ -31,7 +31,7 @@ public:
int32_t SoftbusRegisterService(const char *clientPkgName, const sptr<IRemoteObject> &object) override;
int32_t CreateSessionServer(const char *pkgName, const char *sessionName) override;
int32_t CreateSessionServer(const char *pkgName, const char *sessionName, bool isNormalApp) override;
int32_t RemoveSessionServer(const char *pkgName, const char *sessionName) override;
int32_t OpenSession(const SessionParam *param, TransInfo *info) override;
int32_t OpenAuthSession(const char *sessionName, const ConnectionAddr *addrInfo) override;

View File

@ -78,10 +78,11 @@ int32_t SoftBusServerProxyFrame::SoftbusRegisterService(const char *clientPkgNam
return serverRet;
}
int32_t SoftBusServerProxyFrame::CreateSessionServer(const char *pkgName, const char *sessionName)
int32_t SoftBusServerProxyFrame::CreateSessionServer(const char *pkgName, const char *sessionName, bool isNormalApp)
{
(void)pkgName;
(void)sessionName;
(void)isNormalApp;
return SOFTBUS_OK;
}

View File

@ -34,7 +34,7 @@ void TransServerProxyDeInit(void)
int32_t ServerIpcCreateSessionServer(const char *pkgName, const char *sessionName)
{
return TransCreateSessionServer(pkgName, sessionName, 0, 0);
return TransCreateSessionServer(pkgName, sessionName, 0, 0, false);
}
int32_t ServerIpcRemoveSessionServer(const char *pkgName, const char *sessionName)

View File

@ -28,7 +28,7 @@ public:
int32_t SoftbusRegisterService(const char *clientPkgName, const sptr<IRemoteObject> &object) override;
int32_t CreateSessionServer(const char *pkgName, const char *sessionName) override;
int32_t CreateSessionServer(const char *pkgName, const char *sessionName, bool isNormalApp) override;
int32_t RemoveSessionServer(const char *pkgName, const char *sessionName) override;
int32_t OpenSession(const SessionParam *param, TransInfo *info) override;
int32_t OpenAuthSession(const char *sessionName, const ConnectionAddr *addrInfo) override;

View File

@ -120,7 +120,7 @@ int32_t ServerIpcCreateSessionServer(const char *pkgName, const char *sessionNam
return SOFTBUS_INVALID_PARAM;
}
return proxy->CreateSessionServer(pkgName, sessionName);
return proxy->CreateSessionServer(pkgName, sessionName, false);
}
int32_t ServerIpcRemoveSessionServer(const char *pkgName, const char *sessionName)

View File

@ -67,8 +67,9 @@ int32_t TransServerProxy::SoftbusRegisterService(const char *clientPkgName, cons
return SOFTBUS_OK;
}
int32_t TransServerProxy::CreateSessionServer(const char *pkgName, const char *sessionName)
int32_t TransServerProxy::CreateSessionServer(const char *pkgName, const char *sessionName, bool isNormalApp)
{
(void)isNormalApp;
if (pkgName == nullptr || sessionName == nullptr) {
return SOFTBUS_INVALID_PARAM;
}

View File

@ -212,6 +212,8 @@ void TransClientDeinit(void);
void ClientTransRegLnnOffline(void);
void ClientTransOnUserSwitch(void);
void ClientTransOnLinkDown(const char *networkId, int32_t routeType);
void ClientCleanAllSessionWhenServerDeath(ListNode *sessionServerInfoList);

View File

@ -47,6 +47,8 @@ ClientSessionServer *GetNewSessionServer(SoftBusSecType type, const char *sessio
SessionInfo *CreateNonEncryptSessionInfo(const char *sessionName);
void DestroyAllClientSession(const ClientSessionServer *server, ListNode *destroyList);
void DestroyClientSessionByNetworkId(const ClientSessionServer *server,
const char *networkId, int32_t type, ListNode *destroyList);

View File

@ -1274,6 +1274,23 @@ void ClientTransRegLnnOffline(void)
}
}
void ClientTransOnUserSwitch(void)
{
if (LockClientSessionServerList() != SOFTBUS_OK) {
TRANS_LOGE(TRANS_SDK, "lock failed");
return;
}
TRANS_LOGD(TRANS_SDK, "recv user switch event, clear all socket");
ClientSessionServer *serverNode = NULL;
ListNode destroyList;
ListInit(&destroyList);
LIST_FOR_EACH_ENTRY(serverNode, &(g_clientSessionServerList->list), ClientSessionServer, node) {
DestroyAllClientSession(serverNode, &destroyList);
}
UnlockClientSessionServerList();
(void)ClientDestroySession(&destroyList, SHUTDOWN_REASON_USER_SWICTH);
}
void ClientTransOnLinkDown(const char *networkId, int32_t routeType)
{
if (networkId == NULL) {

View File

@ -333,6 +333,32 @@ static bool ClientTransCheckNeedDel(SessionInfo *sessionNode, int32_t routeType,
return false;
}
void DestroyAllClientSession(const ClientSessionServer *server, ListNode *destroyList)
{
if (server == NULL || destroyList == NULL) {
TRANS_LOGE(TRANS_SDK, "invalid param.");
return;
}
SessionInfo *sessionNode = NULL;
SessionInfo *sessionNodeNext = NULL;
LIST_FOR_EACH_ENTRY_SAFE(sessionNode, sessionNodeNext, &(server->sessionList), SessionInfo, node) {
TRANS_LOGI(TRANS_SDK, "channelId=%{public}d, channelType=%{public}d, routeType=%{public}d",
sessionNode->channelId, sessionNode->channelType, sessionNode->routeType);
DestroySessionInfo *destroyNode = CreateDestroySessionNode(sessionNode, server);
if (destroyNode == NULL) {
continue;
}
if (sessionNode->channelType == CHANNEL_TYPE_UDP && sessionNode->businessType == BUSINESS_TYPE_FILE) {
ClientEmitFileEvent(sessionNode->channelId);
}
DestroySessionId();
ListDelete(&sessionNode->node);
ListAdd(destroyList, &(destroyNode->node));
SoftBusFree(sessionNode);
}
}
void DestroyClientSessionByNetworkId(const ClientSessionServer *server,
const char *networkId, int32_t type, ListNode *destroyList)
{

View File

@ -90,7 +90,12 @@ int32_t TransOnChannelLinkDown(const char *networkId, int32_t routeType)
TRANS_LOGE(TRANS_SDK, "[client] network id is null.");
return SOFTBUS_INVALID_PARAM;
}
bool isUserSwitchEvent = (bool)((routeType >> 10) & 0xff);
if (isUserSwitchEvent) {
TRANS_LOGI(TRANS_SDK, "[client] user switch event.");
ClientTransOnUserSwitch();
return SOFTBUS_OK;
}
ClientTransOnLinkDown(networkId, routeType);
return SOFTBUS_OK;
}

View File

@ -79,9 +79,9 @@ void TransSessionServiceTest::TearDownTestCase(void)
*/
HWTEST_F(TransSessionServiceTest, TransSessionServiceTest01, TestSize.Level1)
{
int32_t ret = TransCreateSessionServer(NULL, g_sessionName, TRANS_TEST_INVALID_UID, TRANS_TEST_INVALID_PID);
int32_t ret = TransCreateSessionServer(NULL, g_sessionName, TRANS_TEST_INVALID_UID, TRANS_TEST_INVALID_PID, false);
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
ret = TransCreateSessionServer(g_pkgName, NULL, TRANS_TEST_INVALID_UID, TRANS_TEST_INVALID_PID);
ret = TransCreateSessionServer(g_pkgName, NULL, TRANS_TEST_INVALID_UID, TRANS_TEST_INVALID_PID, false);
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
}
@ -102,7 +102,7 @@ HWTEST_F(TransSessionServiceTest, TransSessionServiceTest02, TestSize.Level1)
EXPECT_EQ(ret, EOK);
ret = TransSessionServerAddItem(sessionServer);
EXPECT_EQ(ret, SOFTBUS_OK);
ret = TransCreateSessionServer(g_pkgName, g_sessionName, TRANS_TEST_INVALID_UID, TRANS_TEST_INVALID_PID);
ret = TransCreateSessionServer(g_pkgName, g_sessionName, TRANS_TEST_INVALID_UID, TRANS_TEST_INVALID_PID, false);
EXPECT_EQ(ret, SOFTBUS_OK);
ret = TransSessionServerDelItem(g_sessionName);
EXPECT_EQ(ret, SOFTBUS_OK);

View File

@ -137,7 +137,7 @@ static int32_t InitAndCreateSessionServer()
if (ret != SOFTBUS_OK) {
return ret;
}
ret = TransCreateSessionServer(g_pkgName, g_sessionName, TRANS_TEST_INVALID_UID, TRANS_TEST_INVALID_PID);
ret = TransCreateSessionServer(g_pkgName, g_sessionName, TRANS_TEST_INVALID_UID, TRANS_TEST_INVALID_PID, false);
if (ret != SOFTBUS_OK) {
return ret;
}
@ -177,7 +177,7 @@ HWTEST_F(TransAuthChannelTest, GetAppInfoTest001, TestSize.Level1)
bool isClient = true;
ret = GetAppInfo(NULL, TRANS_TEST_CHANNEL_ID, appInfo, isClient);
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
ret = TransCreateSessionServer(g_pkgName, g_sessionName, TRANS_TEST_UID, TRANS_TEST_PID);
ret = TransCreateSessionServer(g_pkgName, g_sessionName, TRANS_TEST_UID, TRANS_TEST_PID, false);
ASSERT_EQ(ret, SOFTBUS_OK);
ret = GetAppInfo(g_sessionName, TRANS_TEST_CHANNEL_ID, appInfo, isClient);
EXPECT_EQ(ret, SOFTBUS_OK);
@ -407,7 +407,7 @@ HWTEST_F(TransAuthChannelTest, OperateAuthChannelInfoTest002, TestSize.Level1)
ASSERT_EQ(ret, SOFTBUS_OK);
ret = TransAuthInit(callback);
ASSERT_EQ(ret, SOFTBUS_OK);
ret = TransCreateSessionServer(g_pkgName, g_sessionName, TRANS_TEST_INVALID_UID, TRANS_TEST_INVALID_PID);
ret = TransCreateSessionServer(g_pkgName, g_sessionName, TRANS_TEST_INVALID_UID, TRANS_TEST_INVALID_PID, false);
ASSERT_EQ(ret, SOFTBUS_OK);
ret = AddAuthChannelInfo(NULL);
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
@ -443,7 +443,7 @@ HWTEST_F(TransAuthChannelTest, OperateAuthChannelInfoTest003, TestSize.Level1)
ASSERT_EQ(ret, SOFTBUS_OK);
ret = TransAuthInit(callback);
ASSERT_EQ(ret, SOFTBUS_OK);
ret = TransCreateSessionServer(g_pkgName, g_sessionName, TRANS_TEST_INVALID_UID, TRANS_TEST_INVALID_PID);
ret = TransCreateSessionServer(g_pkgName, g_sessionName, TRANS_TEST_INVALID_UID, TRANS_TEST_INVALID_PID, false);
ASSERT_EQ(ret, SOFTBUS_OK);
bool isClient = true;
AuthChannelInfo *info = CreateAuthChannelInfo(g_sessionName, isClient);
@ -474,7 +474,7 @@ HWTEST_F(TransAuthChannelTest, OperateAuthChannelInfoTest004, TestSize.Level1)
ASSERT_EQ(ret, SOFTBUS_OK);
ret = TransAuthInit(callback);
ASSERT_EQ(ret, SOFTBUS_OK);
ret = TransCreateSessionServer(g_pkgName, g_sessionName, TRANS_TEST_UID, TRANS_TEST_PID);
ret = TransCreateSessionServer(g_pkgName, g_sessionName, TRANS_TEST_UID, TRANS_TEST_PID, false);
ASSERT_EQ(ret, SOFTBUS_OK);
bool isClient = true;
AuthChannelInfo *info = CreateAuthChannelInfo(g_sessionName, isClient);
@ -621,7 +621,7 @@ HWTEST_F(TransAuthChannelTest, OnRequsetUpdateAuthChannelTest001, TestSize.Level
ret = TestGenerateAppInfo(appInfo);
ASSERT_EQ(ret, SOFTBUS_OK);
bool isClient = true;
ret = TransCreateSessionServer(g_pkgName, g_sessionName, TRANS_TEST_UID, TRANS_TEST_PID);
ret = TransCreateSessionServer(g_pkgName, g_sessionName, TRANS_TEST_UID, TRANS_TEST_PID, false);
ASSERT_EQ(ret, SOFTBUS_OK);
AuthChannelInfo *testinfo = CreateAuthChannelInfo(g_sessionName, isClient);
ASSERT_TRUE(testinfo != nullptr);
@ -630,7 +630,7 @@ HWTEST_F(TransAuthChannelTest, OnRequsetUpdateAuthChannelTest001, TestSize.Level
ASSERT_EQ(ret, SOFTBUS_OK);
ret = OnRequsetUpdateAuthChannel(TRANS_TEST_AUTH_ID, appInfo);
EXPECT_EQ(ret, SOFTBUS_OK);
ret = TransCreateSessionServer(g_pkgName, g_sessionName, TRANS_TEST_UID, TRANS_TEST_PID);
ret = TransCreateSessionServer(g_pkgName, g_sessionName, TRANS_TEST_UID, TRANS_TEST_PID, false);
ASSERT_EQ(ret, SOFTBUS_SERVER_NAME_REPEATED);
AuthChannelInfo *info = CreateAuthChannelInfo(g_sessionName, isClient);
ASSERT_TRUE(info != nullptr);
@ -671,7 +671,7 @@ HWTEST_F(TransAuthChannelTest, OnRequsetUpdateAuthChannelTest002, TestSize.Level
ret = TestGenerateAppInfo(appInfo);
ASSERT_EQ(ret, SOFTBUS_OK);
bool isClient = true;
ret = TransCreateSessionServer(g_pkgName, g_sessionName, TRANS_TEST_UID, TRANS_TEST_PID);
ret = TransCreateSessionServer(g_pkgName, g_sessionName, TRANS_TEST_UID, TRANS_TEST_PID, false);
ASSERT_EQ(ret, SOFTBUS_OK);
AuthChannelInfo *testinfo = CreateAuthChannelInfo(g_sessionName, isClient);
ASSERT_TRUE(testinfo != nullptr);
@ -680,7 +680,7 @@ HWTEST_F(TransAuthChannelTest, OnRequsetUpdateAuthChannelTest002, TestSize.Level
ASSERT_EQ(ret, SOFTBUS_OK);
ret = OnRequsetUpdateAuthChannel(TRANS_TEST_AUTH_ID, appInfo);
EXPECT_NE(ret, SOFTBUS_TRANS_INVALID_CHANNEL_ID);
ret = TransCreateSessionServer(g_pkgName, g_sessionName, TRANS_TEST_UID, TRANS_TEST_PID);
ret = TransCreateSessionServer(g_pkgName, g_sessionName, TRANS_TEST_UID, TRANS_TEST_PID, false);
ASSERT_EQ(ret, SOFTBUS_SERVER_NAME_REPEATED);
DelAuthChannelInfoByAuthId(TRANS_TEST_AUTH_ID);
SoftBusFree(appInfo);
@ -764,7 +764,7 @@ HWTEST_F(TransAuthChannelTest, OnRecvAuthChannelRequestTest003, TestSize.Level1)
ASSERT_EQ(ret, SOFTBUS_OK);
ret = TransAuthInit(callback);
ASSERT_EQ(ret, SOFTBUS_OK);
ret = TransCreateSessionServer(g_pkgName, g_authSessionName, TRANS_TEST_UID, TRANS_TEST_PID);
ret = TransCreateSessionServer(g_pkgName, g_authSessionName, TRANS_TEST_UID, TRANS_TEST_PID, false);
ASSERT_EQ(ret, SOFTBUS_OK);
cJSON *msg = cJSON_CreateObject();
AppInfo *appInfo = (AppInfo *)SoftBusCalloc(sizeof(AppInfo));
@ -812,7 +812,7 @@ HWTEST_F(TransAuthChannelTest, OnDisconnectTest001, TestSize.Level1)
ASSERT_EQ(ret, SOFTBUS_OK);
ret = TransAuthInit(callback);
ASSERT_EQ(ret, SOFTBUS_OK);
ret = TransCreateSessionServer(g_pkgName, g_authSessionName, TRANS_TEST_UID, TRANS_TEST_PID);
ret = TransCreateSessionServer(g_pkgName, g_authSessionName, TRANS_TEST_UID, TRANS_TEST_PID, false);
ASSERT_EQ(ret, SOFTBUS_OK);
bool isClient = true;
AuthChannelInfo *info = CreateAuthChannelInfo(g_authSessionName, isClient);
@ -848,7 +848,7 @@ HWTEST_F(TransAuthChannelTest, TransAuthGetNameByChanIdTest001, TestSize.Level1)
ASSERT_EQ(ret, SOFTBUS_OK);
ret = TransAuthInit(callback);
ASSERT_EQ(ret, SOFTBUS_OK);
ret = TransCreateSessionServer(g_pkgName, g_sessionName, TRANS_TEST_UID, TRANS_TEST_PID);
ret = TransCreateSessionServer(g_pkgName, g_sessionName, TRANS_TEST_UID, TRANS_TEST_PID, false);
ASSERT_EQ(ret, SOFTBUS_OK);
bool isClient = true;
AuthChannelInfo *info = CreateAuthChannelInfo(g_sessionName, isClient);
@ -924,7 +924,7 @@ HWTEST_F(TransAuthChannelTest, TransAuthGetConnOptionByChanIdTest002, TestSize.L
ASSERT_TRUE(connOpt != nullptr);
ret = TransAuthGetConnOptionByChanId(TRANS_TEST_CHANNEL_ID, connOpt);
EXPECT_NE(ret, SOFTBUS_OK);
ret = TransCreateSessionServer(g_pkgName, g_sessionName, TRANS_TEST_UID, TRANS_TEST_PID);
ret = TransCreateSessionServer(g_pkgName, g_sessionName, TRANS_TEST_UID, TRANS_TEST_PID, false);
ASSERT_EQ(ret, SOFTBUS_OK);
bool isClient = true;
AuthChannelInfo *info = CreateAuthChannelInfo(g_sessionName, isClient);
@ -1166,7 +1166,7 @@ HWTEST_F(TransAuthChannelTest, TransOpenAuthMsgChannelTest003, TestSize.Level1)
ASSERT_EQ(ret, SOFTBUS_OK);
ret = TransAuthInit(callback);
ASSERT_EQ(ret, SOFTBUS_OK);
ret = TransCreateSessionServer(g_pkgName, g_sessionName, TRANS_TEST_UID, TRANS_TEST_PID);
ret = TransCreateSessionServer(g_pkgName, g_sessionName, TRANS_TEST_UID, TRANS_TEST_PID, false);
ASSERT_EQ(ret, SOFTBUS_OK);
ret = TransOpenAuthMsgChannel(g_sessionName, &connInfo, &channelId, NULL);

View File

@ -91,7 +91,7 @@ HWTEST_F(BusCenterServerProxyStandardTest, CreateSessionServer_TEST_001, TestSiz
const char *sessionName = "111";
const sptr<IRemoteObject> impl = nullptr;
BusCenterServerProxy servertest(impl);
int32_t ret = servertest.CreateSessionServer(pkgName, sessionName);
int32_t ret = servertest.CreateSessionServer(pkgName, sessionName, false);
EXPECT_EQ(ret, SOFTBUS_OK);
}

View File

@ -141,13 +141,13 @@ HWTEST_F(TransIpcStandardTest, SoftbusRegisterServiceTest002, TestSize.Level0)
HWTEST_F(TransIpcStandardTest, CreateSessionServerTest001, TestSize.Level0)
{
TransServerProxy transServerProxy(nullptr);
int32_t ret = transServerProxy.CreateSessionServer(nullptr, g_sessionName);
int32_t ret = transServerProxy.CreateSessionServer(nullptr, g_sessionName, false);
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
ret = transServerProxy.CreateSessionServer(g_pkgName, nullptr);
ret = transServerProxy.CreateSessionServer(g_pkgName, nullptr, false);
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
ret = transServerProxy.CreateSessionServer(g_pkgName, g_sessionName);
ret = transServerProxy.CreateSessionServer(g_pkgName, g_sessionName, false);
EXPECT_EQ(ret, SOFTBUS_ACCESS_TOKEN_DENIED);
}