Loading system/bta/vc/vc.cc +7 −0 Original line number Diff line number Diff line Loading @@ -117,6 +117,12 @@ class VolumeControlImpl : public VolumeControl { auto device = volume_control_devices_.FindByAddress(address); if (!device) { if (!BTM_IsLinkKeyKnown(address, BT_TRANSPORT_LE)) { log::error("Connecting {} when not bonded", ADDRESS_TO_LOGGABLE_CSTR(address)); callbacks_->OnConnectionState(ConnectionState::DISCONNECTED, address); return; } volume_control_devices_.Add(address, true); } else { device->connecting_actively = true; Loading Loading @@ -671,6 +677,7 @@ class VolumeControlImpl : public VolumeControl { BTA_GATTC_CancelOpen(gatt_if_, address, false); Disconnect(address); volume_control_devices_.Remove(address); } void OnGattDisconnected(uint16_t connection_id, tGATT_IF /*client_if*/, Loading system/bta/vc/vc_test.cc +31 −0 Original line number Diff line number Diff line Loading @@ -246,6 +246,9 @@ class VolumeControlTest : public ::testing::Test { gatt::SetMockBtaGattQueue(&gatt_queue); callbacks.reset(new MockVolumeControlCallbacks()); ON_CALL(btm_interface, IsLinkKeyKnown(_, _)) .WillByDefault(DoAll(Return(true))); // default action for GetCharacteristic function call ON_CALL(gatt_interface, GetCharacteristic(_, _)) .WillByDefault( Loading Loading @@ -568,6 +571,34 @@ TEST_F(VolumeControlTest, test_connect) { TestAppUnregister(); } TEST_F(VolumeControlTest, test_connect_after_remove) { TestAppRegister(); const RawAddress test_address = GetTestAddress(0); uint16_t conn_id = 1; TestConnect(test_address); GetConnectedEvent(test_address, conn_id); Mock::VerifyAndClearExpectations(callbacks.get()); EXPECT_CALL(*callbacks, OnConnectionState(ConnectionState::DISCONNECTED, test_address)) .Times(1); TestRemove(test_address, conn_id); Mock::VerifyAndClearExpectations(callbacks.get()); EXPECT_CALL(*callbacks, OnConnectionState(ConnectionState::DISCONNECTED, test_address)) .Times(1); ON_CALL(btm_interface, IsLinkKeyKnown(_, _)) .WillByDefault(DoAll(Return(false))); VolumeControl::Get()->Connect(test_address); Mock::VerifyAndClearExpectations(callbacks.get()); TestAppUnregister(); } TEST_F(VolumeControlTest, test_reconnect_after_interrupted_discovery) { const RawAddress test_address = GetTestAddress(0); Loading Loading
system/bta/vc/vc.cc +7 −0 Original line number Diff line number Diff line Loading @@ -117,6 +117,12 @@ class VolumeControlImpl : public VolumeControl { auto device = volume_control_devices_.FindByAddress(address); if (!device) { if (!BTM_IsLinkKeyKnown(address, BT_TRANSPORT_LE)) { log::error("Connecting {} when not bonded", ADDRESS_TO_LOGGABLE_CSTR(address)); callbacks_->OnConnectionState(ConnectionState::DISCONNECTED, address); return; } volume_control_devices_.Add(address, true); } else { device->connecting_actively = true; Loading Loading @@ -671,6 +677,7 @@ class VolumeControlImpl : public VolumeControl { BTA_GATTC_CancelOpen(gatt_if_, address, false); Disconnect(address); volume_control_devices_.Remove(address); } void OnGattDisconnected(uint16_t connection_id, tGATT_IF /*client_if*/, Loading
system/bta/vc/vc_test.cc +31 −0 Original line number Diff line number Diff line Loading @@ -246,6 +246,9 @@ class VolumeControlTest : public ::testing::Test { gatt::SetMockBtaGattQueue(&gatt_queue); callbacks.reset(new MockVolumeControlCallbacks()); ON_CALL(btm_interface, IsLinkKeyKnown(_, _)) .WillByDefault(DoAll(Return(true))); // default action for GetCharacteristic function call ON_CALL(gatt_interface, GetCharacteristic(_, _)) .WillByDefault( Loading Loading @@ -568,6 +571,34 @@ TEST_F(VolumeControlTest, test_connect) { TestAppUnregister(); } TEST_F(VolumeControlTest, test_connect_after_remove) { TestAppRegister(); const RawAddress test_address = GetTestAddress(0); uint16_t conn_id = 1; TestConnect(test_address); GetConnectedEvent(test_address, conn_id); Mock::VerifyAndClearExpectations(callbacks.get()); EXPECT_CALL(*callbacks, OnConnectionState(ConnectionState::DISCONNECTED, test_address)) .Times(1); TestRemove(test_address, conn_id); Mock::VerifyAndClearExpectations(callbacks.get()); EXPECT_CALL(*callbacks, OnConnectionState(ConnectionState::DISCONNECTED, test_address)) .Times(1); ON_CALL(btm_interface, IsLinkKeyKnown(_, _)) .WillByDefault(DoAll(Return(false))); VolumeControl::Get()->Connect(test_address); Mock::VerifyAndClearExpectations(callbacks.get()); TestAppUnregister(); } TEST_F(VolumeControlTest, test_reconnect_after_interrupted_discovery) { const RawAddress test_address = GetTestAddress(0); Loading