Loading system/profile/avrcp/connection_handler.cc +3 −3 Original line number Diff line number Diff line Loading @@ -243,7 +243,7 @@ void ConnectionHandler::InitiatorControlCb(uint8_t handle, uint8_t event, case AVRC_CLOSE_IND_EVT: { LOG(INFO) << __PRETTY_FUNCTION__ << ": Connection Closed Event"; if (device_map_[handle] == nullptr) { if (device_map_.find(handle) == device_map_.end()) { LOG(WARNING) << "Connection Close received from device that doesn't exist"; return; Loading Loading @@ -327,7 +327,7 @@ void ConnectionHandler::AcceptorControlCb(uint8_t handle, uint8_t event, case AVRC_CLOSE_IND_EVT: { LOG(INFO) << __PRETTY_FUNCTION__ << ": Connection Closed Event"; if (device_map_[handle] == nullptr) { if (device_map_.find(handle) == device_map_.end()) { LOG(WARNING) << "Connection Close received from device that doesn't exist"; return; Loading system/profile/avrcp/tests/avrcp_connection_handler_test.cc +25 −1 Original line number Diff line number Diff line Loading @@ -109,6 +109,30 @@ TEST_F(AvrcpConnectionHandlerTest, initializeTest) { ConnectionHandler::CleanUp(); } // Check that disconnecting without an active connection TEST_F(AvrcpConnectionHandlerTest, notConnectedDisconnectTest) { // Set an Expectation that Open will be called twice as an acceptor and save // the connection callback once it is called. tAVRC_CONN_CB conn_cb; EXPECT_CALL(mock_avrcp_, Open(_, _, RawAddress::kAny)) .Times(1) .WillOnce( DoAll(SetArgPointee<0>(1), SaveArgPointee<1>(&conn_cb), Return(0))); // Initialize the interface auto bound_callback = base::Bind(&MockFunction<void(device_ptr)>::Call, base::Unretained(&device_cb)); ASSERT_TRUE(ConnectionHandler::Initialize(bound_callback, &mock_avrcp_, &mock_sdp_, &mock_volume_)); connection_handler_ = ConnectionHandler::Get(); // Call the callback with a message saying the connection has closed conn_cb.ctrl_cback.Run(1, AVRC_CLOSE_IND_EVT, 0, &RawAddress::kAny); connection_handler_ = nullptr; ConnectionHandler::CleanUp(); }; // Check that we can handle having a remote device connect to us, start SDP, and // open another acceptor connection TEST_F(AvrcpConnectionHandlerTest, remoteDeviceConnectionTest) { Loading Loading
system/profile/avrcp/connection_handler.cc +3 −3 Original line number Diff line number Diff line Loading @@ -243,7 +243,7 @@ void ConnectionHandler::InitiatorControlCb(uint8_t handle, uint8_t event, case AVRC_CLOSE_IND_EVT: { LOG(INFO) << __PRETTY_FUNCTION__ << ": Connection Closed Event"; if (device_map_[handle] == nullptr) { if (device_map_.find(handle) == device_map_.end()) { LOG(WARNING) << "Connection Close received from device that doesn't exist"; return; Loading Loading @@ -327,7 +327,7 @@ void ConnectionHandler::AcceptorControlCb(uint8_t handle, uint8_t event, case AVRC_CLOSE_IND_EVT: { LOG(INFO) << __PRETTY_FUNCTION__ << ": Connection Closed Event"; if (device_map_[handle] == nullptr) { if (device_map_.find(handle) == device_map_.end()) { LOG(WARNING) << "Connection Close received from device that doesn't exist"; return; Loading
system/profile/avrcp/tests/avrcp_connection_handler_test.cc +25 −1 Original line number Diff line number Diff line Loading @@ -109,6 +109,30 @@ TEST_F(AvrcpConnectionHandlerTest, initializeTest) { ConnectionHandler::CleanUp(); } // Check that disconnecting without an active connection TEST_F(AvrcpConnectionHandlerTest, notConnectedDisconnectTest) { // Set an Expectation that Open will be called twice as an acceptor and save // the connection callback once it is called. tAVRC_CONN_CB conn_cb; EXPECT_CALL(mock_avrcp_, Open(_, _, RawAddress::kAny)) .Times(1) .WillOnce( DoAll(SetArgPointee<0>(1), SaveArgPointee<1>(&conn_cb), Return(0))); // Initialize the interface auto bound_callback = base::Bind(&MockFunction<void(device_ptr)>::Call, base::Unretained(&device_cb)); ASSERT_TRUE(ConnectionHandler::Initialize(bound_callback, &mock_avrcp_, &mock_sdp_, &mock_volume_)); connection_handler_ = ConnectionHandler::Get(); // Call the callback with a message saying the connection has closed conn_cb.ctrl_cback.Run(1, AVRC_CLOSE_IND_EVT, 0, &RawAddress::kAny); connection_handler_ = nullptr; ConnectionHandler::CleanUp(); }; // Check that we can handle having a remote device connect to us, start SDP, and // open another acceptor connection TEST_F(AvrcpConnectionHandlerTest, remoteDeviceConnectionTest) { Loading