Loading system/bta/has/has_client.cc +8 −1 Original line number Diff line number Diff line Loading @@ -150,7 +150,14 @@ class HasClientImpl : public HasClient { ~HasClientImpl() override = default; void Connect(const RawAddress& address) override { DLOG(INFO) << __func__ << ": " << ADDRESS_TO_LOGGABLE_STR(address); log::info("{}", ADDRESS_TO_LOGGABLE_CSTR(address)); if (!BTM_IsLinkKeyKnown(address, BT_TRANSPORT_LE)) { log::error("Connecting {} when not bonded", ADDRESS_TO_LOGGABLE_CSTR(address)); callbacks_->OnConnectionState(ConnectionState::DISCONNECTED, address); return; } std::vector<RawAddress> addresses = {address}; auto csis_api = CsisClient::Get(); Loading system/bta/has/has_client_test.cc +24 −0 Original line number Diff line number Diff line Loading @@ -663,6 +663,9 @@ class HasClientTestBase : public ::testing::Test { encryption_result = true; ON_CALL(btm_interface, IsLinkKeyKnown(_, _)) .WillByDefault(DoAll(Return(true))); ON_CALL(btm_interface, SetEncryption(_, _, _, _, _)) .WillByDefault( Invoke([this](const RawAddress& bd_addr, tBT_TRANSPORT transport, Loading Loading @@ -1231,6 +1234,27 @@ TEST_F(HasClientTest, test_add_from_storage) { TestAddFromStorage(GetTestAddress(2), 0, false); } TEST_F(HasClientTest, test_connect_after_remove) { const RawAddress test_address = GetTestAddress(1); /* Override the default action to prevent us sendind the connected event */ EXPECT_CALL(gatt_interface, Open(gatt_if, test_address, BTM_BLE_DIRECT_CONNECTION, _)) .WillOnce(Return()); HasClient::Get()->Connect(test_address); TestDisconnect(test_address, GATT_INVALID_CONN_ID); Mock::VerifyAndClearExpectations(&gatt_interface); EXPECT_CALL(*callbacks, OnConnectionState(ConnectionState::DISCONNECTED, test_address)); // Device has no Link Key ON_CALL(btm_interface, IsLinkKeyKnown(test_address, _)) .WillByDefault(DoAll(Return(true))); HasClient::Get()->Connect(test_address); Mock::VerifyAndClearExpectations(&callbacks); } TEST_F(HasClientTest, test_disconnect_non_connected) { const RawAddress test_address = GetTestAddress(1); Loading Loading
system/bta/has/has_client.cc +8 −1 Original line number Diff line number Diff line Loading @@ -150,7 +150,14 @@ class HasClientImpl : public HasClient { ~HasClientImpl() override = default; void Connect(const RawAddress& address) override { DLOG(INFO) << __func__ << ": " << ADDRESS_TO_LOGGABLE_STR(address); log::info("{}", ADDRESS_TO_LOGGABLE_CSTR(address)); if (!BTM_IsLinkKeyKnown(address, BT_TRANSPORT_LE)) { log::error("Connecting {} when not bonded", ADDRESS_TO_LOGGABLE_CSTR(address)); callbacks_->OnConnectionState(ConnectionState::DISCONNECTED, address); return; } std::vector<RawAddress> addresses = {address}; auto csis_api = CsisClient::Get(); Loading
system/bta/has/has_client_test.cc +24 −0 Original line number Diff line number Diff line Loading @@ -663,6 +663,9 @@ class HasClientTestBase : public ::testing::Test { encryption_result = true; ON_CALL(btm_interface, IsLinkKeyKnown(_, _)) .WillByDefault(DoAll(Return(true))); ON_CALL(btm_interface, SetEncryption(_, _, _, _, _)) .WillByDefault( Invoke([this](const RawAddress& bd_addr, tBT_TRANSPORT transport, Loading Loading @@ -1231,6 +1234,27 @@ TEST_F(HasClientTest, test_add_from_storage) { TestAddFromStorage(GetTestAddress(2), 0, false); } TEST_F(HasClientTest, test_connect_after_remove) { const RawAddress test_address = GetTestAddress(1); /* Override the default action to prevent us sendind the connected event */ EXPECT_CALL(gatt_interface, Open(gatt_if, test_address, BTM_BLE_DIRECT_CONNECTION, _)) .WillOnce(Return()); HasClient::Get()->Connect(test_address); TestDisconnect(test_address, GATT_INVALID_CONN_ID); Mock::VerifyAndClearExpectations(&gatt_interface); EXPECT_CALL(*callbacks, OnConnectionState(ConnectionState::DISCONNECTED, test_address)); // Device has no Link Key ON_CALL(btm_interface, IsLinkKeyKnown(test_address, _)) .WillByDefault(DoAll(Return(true))); HasClient::Get()->Connect(test_address); Mock::VerifyAndClearExpectations(&callbacks); } TEST_F(HasClientTest, test_disconnect_non_connected) { const RawAddress test_address = GetTestAddress(1); Loading