diff --git a/core/connection/ble/src/softbus_conn_ble_manager.c b/core/connection/ble/src/softbus_conn_ble_manager.c index 54bda32c0..b700fcfac 100644 --- a/core/connection/ble/src/softbus_conn_ble_manager.c +++ b/core/connection/ble/src/softbus_conn_ble_manager.c @@ -355,13 +355,6 @@ static void BleNotifyDeviceConnectResult(const ConnBleDevice *device, ConnBleCon } return; } - UpdateOption option = { - .type = CONNECT_BLE, - .bleOption = { - .priority = CONN_BLE_PRIORITY_BALANCED, - } - }; - BleUpdateConnection(connection->connectionId, &option); ConnectionInfo info = { 0 }; int32_t status = BleConvert2ConnectionInfo(connection, &info); @@ -686,6 +679,13 @@ static void BleClientConnected(uint32_t connectionId) return; } ConnRemoveMsgFromLooper(&g_bleManagerSyncHandler, BLE_MGR_MSG_CONNECT_TIMEOUT, connectionId, 0, NULL); + UpdateOption option = { + .type = CONNECT_BLE, + .bleOption = { + .priority = CONN_BLE_PRIORITY_BALANCED, + } + }; + BleUpdateConnection(connectionId, &option); CONN_LOGI( CONN_BLE, "ble client connect success, clientId=%{public}d, addr=%{public}s", connectionId, anomizeAddress); connection->underlayerFastConnectFailedScanFailure = false; @@ -1594,6 +1594,7 @@ static void DataReceivedFunc(SoftBusMessage *msg) { CONN_CHECK_AND_RETURN_LOGW(msg->obj != NULL, CONN_BLE, "obj is null"); ConnBleDataReceivedContext *ctx = (ConnBleDataReceivedContext *)msg->obj; + CONN_CHECK_AND_RETURN_LOGW(ctx->data != NULL, CONN_BLE, "data is null"); if (g_bleManager.state->dataReceived == NULL) { SoftBusFree(ctx->data); return; diff --git a/core/connection/br/src/softbus_conn_br_manager.c b/core/connection/br/src/softbus_conn_br_manager.c index 85144d917..1085a3dce 100644 --- a/core/connection/br/src/softbus_conn_br_manager.c +++ b/core/connection/br/src/softbus_conn_br_manager.c @@ -1141,6 +1141,7 @@ static void DataReceivedFunc(SoftBusMessage *msg) { CONN_CHECK_AND_RETURN_LOGW(msg->obj != NULL, CONN_BR, "obj is null"); ConnBrDataReceivedContext *ctx = (ConnBrDataReceivedContext *)msg->obj; + CONN_CHECK_AND_RETURN_LOGW(ctx->data != NULL, CONN_BR, "data is null"); if (g_brManager.state->dataReceived == NULL) { SoftBusFree(ctx->data); return; diff --git a/tests/core/connection/br/br_connection_test.cpp b/tests/core/connection/br/br_connection_test.cpp index 5d70c2717..b2e5cd6f2 100644 --- a/tests/core/connection/br/br_connection_test.cpp +++ b/tests/core/connection/br/br_connection_test.cpp @@ -374,9 +374,9 @@ HWTEST_F(ConnectionBrConnectionTest, BrManagerTest008, TestSize.Level1) LocalListenerInfo *info = (LocalListenerInfo *)SoftBusCalloc(sizeof(LocalListenerInfo)); ASSERT_NE(nullptr, info); info->type = CONNECT_BR; - EXPECT_CALL(brMock, SoftBusThreadCreate).WillOnce(Return(SOFTBUS_ERR)); + EXPECT_CALL(brMock, SoftBusThreadCreate).WillOnce(Return(SOFTBUS_INVALID_PARAM)); int32_t ret = g_connectFuncInterface->StartLocalListening(info); - EXPECT_EQ(SOFTBUS_ERR, ret); + EXPECT_EQ(SOFTBUS_INVALID_PARAM, ret); EXPECT_CALL(brMock, SoftBusThreadCreate).WillOnce(Return(SOFTBUS_OK)); ret = g_connectFuncInterface->StartLocalListening(info);