Loading system/stack/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -830,6 +830,7 @@ cc_test { "test/common/mock_btm_layer.cc", "test/common/mock_l2cap_layer.cc", "test/common/stack_test_packet_utils.cc", "test/rfcomm/stack_rfcomm_port_test.cc", "test/rfcomm/stack_rfcomm_test.cc", "test/rfcomm/stack_rfcomm_test_main.cc", "test/rfcomm/stack_rfcomm_test_utils.cc", Loading system/stack/rfcomm/port_api.cc +12 −9 Original line number Diff line number Diff line Loading @@ -493,6 +493,17 @@ int PORT_CheckConnection(uint16_t handle, RawAddress* bd_addr, * bd_addr - bd_addr of the peer * ******************************************************************************/ static const tPORT* get_port_from_mcb(const tRFC_MCB* multiplexer_cb) { tPORT* p_port = nullptr; for (tPORT& port : rfc_cb.port.port) { if (port.rfc.p_mcb == multiplexer_cb) { return &port; } } return nullptr; } bool PORT_IsOpening(RawAddress* bd_addr) { /* Check for any rfc_mcb which is in the middle of opening. */ for (auto& multiplexer_cb : rfc_cb.port.rfc_mcb) { Loading @@ -505,15 +516,7 @@ bool PORT_IsOpening(RawAddress* bd_addr) { } if (multiplexer_cb.state == RFC_MX_STATE_CONNECTED) { tPORT* p_port = nullptr; for (tPORT& port : rfc_cb.port.port) { if (port.rfc.p_mcb == &multiplexer_cb) { p_port = &port; break; } } const tPORT* p_port = get_port_from_mcb(&multiplexer_cb); log::info("RFC_MX_STATE_CONNECTED, found_port={}, tRFC_PORT_STATE={}", (p_port != nullptr) ? "T" : "F", (p_port != nullptr) ? p_port->rfc.state : 0); Loading system/stack/test/rfcomm/stack_rfcomm_port_test.cc 0 → 100644 +57 −0 Original line number Diff line number Diff line /* * Copyright 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <gtest/gtest.h> #include "stack/include/port_api.h" #include "stack/rfcomm/rfc_int.h" #include "types/raw_address.h" namespace { const RawAddress kRawAddress = RawAddress({0x11, 0x22, 0x33, 0x44, 0x55, 0x66}); } // namespace class StackRfcommPortTest : public ::testing::Test { protected: void SetUp() override {} void TearDown() override {} private: }; TEST_F(StackRfcommPortTest, PORT_IsOpening__basic) { RawAddress bd_addr(kRawAddress); rfc_cb.port.rfc_mcb[0].state = RFC_MX_STATE_IDLE; ASSERT_FALSE(PORT_IsOpening(&bd_addr)); rfc_cb.port.rfc_mcb[0].state = RFC_MX_STATE_WAIT_CONN_CNF; ASSERT_TRUE(PORT_IsOpening(&bd_addr)); rfc_cb.port.rfc_mcb[0].state = RFC_MX_STATE_CONFIGURE; ASSERT_TRUE(PORT_IsOpening(&bd_addr)); rfc_cb.port.rfc_mcb[0].state = RFC_MX_STATE_SABME_WAIT_UA; ASSERT_TRUE(PORT_IsOpening(&bd_addr)); rfc_cb.port.rfc_mcb[0].state = RFC_MX_STATE_WAIT_SABME; ASSERT_TRUE(PORT_IsOpening(&bd_addr)); rfc_cb.port.rfc_mcb[0].state = RFC_MX_STATE_CONNECTED; rfc_cb.port.port[0].rfc.p_mcb = &rfc_cb.port.rfc_mcb[0]; rfc_cb.port.port[0].rfc.state = RFC_STATE_OPENED; ASSERT_FALSE(PORT_IsOpening(&bd_addr)); rfc_cb.port.port[0].rfc.state = RFC_STATE_TERM_WAIT_SEC_CHECK; ASSERT_TRUE(PORT_IsOpening(&bd_addr)); rfc_cb.port.rfc_mcb[0].state = RFC_MX_STATE_DISC_WAIT_UA; ASSERT_FALSE(PORT_IsOpening(&bd_addr)); } Loading
system/stack/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -830,6 +830,7 @@ cc_test { "test/common/mock_btm_layer.cc", "test/common/mock_l2cap_layer.cc", "test/common/stack_test_packet_utils.cc", "test/rfcomm/stack_rfcomm_port_test.cc", "test/rfcomm/stack_rfcomm_test.cc", "test/rfcomm/stack_rfcomm_test_main.cc", "test/rfcomm/stack_rfcomm_test_utils.cc", Loading
system/stack/rfcomm/port_api.cc +12 −9 Original line number Diff line number Diff line Loading @@ -493,6 +493,17 @@ int PORT_CheckConnection(uint16_t handle, RawAddress* bd_addr, * bd_addr - bd_addr of the peer * ******************************************************************************/ static const tPORT* get_port_from_mcb(const tRFC_MCB* multiplexer_cb) { tPORT* p_port = nullptr; for (tPORT& port : rfc_cb.port.port) { if (port.rfc.p_mcb == multiplexer_cb) { return &port; } } return nullptr; } bool PORT_IsOpening(RawAddress* bd_addr) { /* Check for any rfc_mcb which is in the middle of opening. */ for (auto& multiplexer_cb : rfc_cb.port.rfc_mcb) { Loading @@ -505,15 +516,7 @@ bool PORT_IsOpening(RawAddress* bd_addr) { } if (multiplexer_cb.state == RFC_MX_STATE_CONNECTED) { tPORT* p_port = nullptr; for (tPORT& port : rfc_cb.port.port) { if (port.rfc.p_mcb == &multiplexer_cb) { p_port = &port; break; } } const tPORT* p_port = get_port_from_mcb(&multiplexer_cb); log::info("RFC_MX_STATE_CONNECTED, found_port={}, tRFC_PORT_STATE={}", (p_port != nullptr) ? "T" : "F", (p_port != nullptr) ? p_port->rfc.state : 0); Loading
system/stack/test/rfcomm/stack_rfcomm_port_test.cc 0 → 100644 +57 −0 Original line number Diff line number Diff line /* * Copyright 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <gtest/gtest.h> #include "stack/include/port_api.h" #include "stack/rfcomm/rfc_int.h" #include "types/raw_address.h" namespace { const RawAddress kRawAddress = RawAddress({0x11, 0x22, 0x33, 0x44, 0x55, 0x66}); } // namespace class StackRfcommPortTest : public ::testing::Test { protected: void SetUp() override {} void TearDown() override {} private: }; TEST_F(StackRfcommPortTest, PORT_IsOpening__basic) { RawAddress bd_addr(kRawAddress); rfc_cb.port.rfc_mcb[0].state = RFC_MX_STATE_IDLE; ASSERT_FALSE(PORT_IsOpening(&bd_addr)); rfc_cb.port.rfc_mcb[0].state = RFC_MX_STATE_WAIT_CONN_CNF; ASSERT_TRUE(PORT_IsOpening(&bd_addr)); rfc_cb.port.rfc_mcb[0].state = RFC_MX_STATE_CONFIGURE; ASSERT_TRUE(PORT_IsOpening(&bd_addr)); rfc_cb.port.rfc_mcb[0].state = RFC_MX_STATE_SABME_WAIT_UA; ASSERT_TRUE(PORT_IsOpening(&bd_addr)); rfc_cb.port.rfc_mcb[0].state = RFC_MX_STATE_WAIT_SABME; ASSERT_TRUE(PORT_IsOpening(&bd_addr)); rfc_cb.port.rfc_mcb[0].state = RFC_MX_STATE_CONNECTED; rfc_cb.port.port[0].rfc.p_mcb = &rfc_cb.port.rfc_mcb[0]; rfc_cb.port.port[0].rfc.state = RFC_STATE_OPENED; ASSERT_FALSE(PORT_IsOpening(&bd_addr)); rfc_cb.port.port[0].rfc.state = RFC_STATE_TERM_WAIT_SEC_CHECK; ASSERT_TRUE(PORT_IsOpening(&bd_addr)); rfc_cb.port.rfc_mcb[0].state = RFC_MX_STATE_DISC_WAIT_UA; ASSERT_FALSE(PORT_IsOpening(&bd_addr)); }