Loading system/packet/tests/avrcp/avrcp_test_packets.h +5 −1 Original line number Diff line number Diff line Loading @@ -301,8 +301,12 @@ std::vector<uint8_t> get_item_attributes_song_response = { 0x72, 0x74, 0x69, 0x73, 0x74, 0x00, 0x00, 0x00, 0x03, 0x00, 0x6a, 0x00, 0x0a, 0x54, 0x65, 0x73, 0x74, 0x20, 0x41, 0x6c, 0x62, 0x75, 0x6d}; // AVRCP Set Addressed Player Request with player_id = 1 // AVRCP Set Addressed Player Request with player_id = 0 std::vector<uint8_t> set_addressed_player_request = { 0x00, 0x48, 0x00, 0x00, 0x19, 0x58, 0x60, 0x00, 0x00, 0x02, 0x00, 0x00}; // AVRCP Set Addressed Player Request with player_id = 1 std::vector<uint8_t> set_addressed_player_id_1_request = { 0x00, 0x48, 0x00, 0x00, 0x19, 0x58, 0x60, 0x00, 0x00, 0x02, 0x00, 0x01}; // AVRCP Set Addressed Player Response with status success Loading system/packet/tests/avrcp/set_addressed_player_packet_test.cc +2 −2 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ TEST(SetAddressedPlayerRequestTest, getterTest) { auto test_packet = TestSetAddrPlayerPacket::Make(set_addressed_player_request); ASSERT_EQ(test_packet->GetPlayerId(), 0x0001u); ASSERT_EQ(test_packet->GetPlayerId(), 0x0000u); } TEST(SetAddressedPlayerRequestTest, validTest) { Loading system/profile/avrcp/device.cc +21 −3 Original line number Diff line number Diff line Loading @@ -126,9 +126,9 @@ void Device::VendorPacketHandler(uint8_t label, // this currently since the current implementation only has one // player and the player will never change, but we need it for a // more complete implementation. auto response = RejectBuilder::MakeBuilder( CommandPdu::SET_ADDRESSED_PLAYER, Status::INVALID_PLAYER_ID); send_message(label, false, std::move(response)); media_interface_->GetMediaPlayerList(base::Bind( &Device::HandleSetAddressedPlayer, weak_ptr_factory_.GetWeakPtr(), label, Packet::Specialize<SetAddressedPlayerRequest>(pkt))); } break; default: { Loading Loading @@ -626,6 +626,24 @@ void Device::HandlePlayItem(uint8_t label, send_message(label, false, std::move(response)); } void Device::HandleSetAddressedPlayer( uint8_t label, std::shared_ptr<SetAddressedPlayerRequest> pkt, uint16_t curr_player, std::vector<MediaPlayerInfo> players) { DEVICE_VLOG(2) << __func__ << ": PlayerId=" << pkt->GetPlayerId(); if (curr_player != pkt->GetPlayerId()) { DEVICE_VLOG(2) << "Reject invalid addressed player ID"; auto response = RejectBuilder::MakeBuilder(CommandPdu::SET_ADDRESSED_PLAYER, Status::INVALID_PLAYER_ID); send_message(label, false, std::move(response)); return; } auto response = SetAddressedPlayerResponseBuilder::MakeBuilder(Status::NO_ERROR); send_message(label, false, std::move(response)); } void Device::BrowseMessageReceived(uint8_t label, std::shared_ptr<BrowsePacket> pkt) { DEVICE_VLOG(1) << __func__ << ": pdu=" << pkt->GetPdu(); Loading system/profile/avrcp/device.h +5 −0 Original line number Diff line number Diff line Loading @@ -210,6 +210,11 @@ class Device { virtual void HandlePlayItem(uint8_t label, std::shared_ptr<PlayItemRequest> request); // SET ADDRESSED PLAYER virtual void HandleSetAddressedPlayer( uint8_t label, std::shared_ptr<SetAddressedPlayerRequest> request, uint16_t curr_player, std::vector<MediaPlayerInfo> players); /******************** * MESSAGE REQUESTS ********************/ Loading system/profile/avrcp/tests/avrcp_device_test.cc +18 −1 Original line number Diff line number Diff line Loading @@ -713,9 +713,26 @@ TEST_F(AvrcpDeviceTest, setAddressedPlayerTest) { test_device->RegisterInterfaces(&interface, &a2dp_interface, nullptr); auto set_addr_player_rsp = RejectBuilder::MakeBuilder( MediaPlayerInfo info = {0, "Test Player", true}; std::vector<MediaPlayerInfo> list = {info}; EXPECT_CALL(interface, GetMediaPlayerList(_)) .WillRepeatedly(InvokeCb<0>(0, list)); auto set_addr_player_rej_rsp = RejectBuilder::MakeBuilder( CommandPdu::SET_ADDRESSED_PLAYER, Status::INVALID_PLAYER_ID); EXPECT_CALL(response_cb, Call(1, false, matchPacket(std::move(set_addr_player_rej_rsp)))) .Times(1); auto player_id_1_request = TestAvrcpPacket::Make(set_addressed_player_id_1_request); SendMessage(1, player_id_1_request); auto set_addr_player_rsp = SetAddressedPlayerResponseBuilder::MakeBuilder(Status::NO_ERROR); EXPECT_CALL(response_cb, Call(1, false, matchPacket(std::move(set_addr_player_rsp)))) .Times(1); Loading Loading
system/packet/tests/avrcp/avrcp_test_packets.h +5 −1 Original line number Diff line number Diff line Loading @@ -301,8 +301,12 @@ std::vector<uint8_t> get_item_attributes_song_response = { 0x72, 0x74, 0x69, 0x73, 0x74, 0x00, 0x00, 0x00, 0x03, 0x00, 0x6a, 0x00, 0x0a, 0x54, 0x65, 0x73, 0x74, 0x20, 0x41, 0x6c, 0x62, 0x75, 0x6d}; // AVRCP Set Addressed Player Request with player_id = 1 // AVRCP Set Addressed Player Request with player_id = 0 std::vector<uint8_t> set_addressed_player_request = { 0x00, 0x48, 0x00, 0x00, 0x19, 0x58, 0x60, 0x00, 0x00, 0x02, 0x00, 0x00}; // AVRCP Set Addressed Player Request with player_id = 1 std::vector<uint8_t> set_addressed_player_id_1_request = { 0x00, 0x48, 0x00, 0x00, 0x19, 0x58, 0x60, 0x00, 0x00, 0x02, 0x00, 0x01}; // AVRCP Set Addressed Player Response with status success Loading
system/packet/tests/avrcp/set_addressed_player_packet_test.cc +2 −2 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ TEST(SetAddressedPlayerRequestTest, getterTest) { auto test_packet = TestSetAddrPlayerPacket::Make(set_addressed_player_request); ASSERT_EQ(test_packet->GetPlayerId(), 0x0001u); ASSERT_EQ(test_packet->GetPlayerId(), 0x0000u); } TEST(SetAddressedPlayerRequestTest, validTest) { Loading
system/profile/avrcp/device.cc +21 −3 Original line number Diff line number Diff line Loading @@ -126,9 +126,9 @@ void Device::VendorPacketHandler(uint8_t label, // this currently since the current implementation only has one // player and the player will never change, but we need it for a // more complete implementation. auto response = RejectBuilder::MakeBuilder( CommandPdu::SET_ADDRESSED_PLAYER, Status::INVALID_PLAYER_ID); send_message(label, false, std::move(response)); media_interface_->GetMediaPlayerList(base::Bind( &Device::HandleSetAddressedPlayer, weak_ptr_factory_.GetWeakPtr(), label, Packet::Specialize<SetAddressedPlayerRequest>(pkt))); } break; default: { Loading Loading @@ -626,6 +626,24 @@ void Device::HandlePlayItem(uint8_t label, send_message(label, false, std::move(response)); } void Device::HandleSetAddressedPlayer( uint8_t label, std::shared_ptr<SetAddressedPlayerRequest> pkt, uint16_t curr_player, std::vector<MediaPlayerInfo> players) { DEVICE_VLOG(2) << __func__ << ": PlayerId=" << pkt->GetPlayerId(); if (curr_player != pkt->GetPlayerId()) { DEVICE_VLOG(2) << "Reject invalid addressed player ID"; auto response = RejectBuilder::MakeBuilder(CommandPdu::SET_ADDRESSED_PLAYER, Status::INVALID_PLAYER_ID); send_message(label, false, std::move(response)); return; } auto response = SetAddressedPlayerResponseBuilder::MakeBuilder(Status::NO_ERROR); send_message(label, false, std::move(response)); } void Device::BrowseMessageReceived(uint8_t label, std::shared_ptr<BrowsePacket> pkt) { DEVICE_VLOG(1) << __func__ << ": pdu=" << pkt->GetPdu(); Loading
system/profile/avrcp/device.h +5 −0 Original line number Diff line number Diff line Loading @@ -210,6 +210,11 @@ class Device { virtual void HandlePlayItem(uint8_t label, std::shared_ptr<PlayItemRequest> request); // SET ADDRESSED PLAYER virtual void HandleSetAddressedPlayer( uint8_t label, std::shared_ptr<SetAddressedPlayerRequest> request, uint16_t curr_player, std::vector<MediaPlayerInfo> players); /******************** * MESSAGE REQUESTS ********************/ Loading
system/profile/avrcp/tests/avrcp_device_test.cc +18 −1 Original line number Diff line number Diff line Loading @@ -713,9 +713,26 @@ TEST_F(AvrcpDeviceTest, setAddressedPlayerTest) { test_device->RegisterInterfaces(&interface, &a2dp_interface, nullptr); auto set_addr_player_rsp = RejectBuilder::MakeBuilder( MediaPlayerInfo info = {0, "Test Player", true}; std::vector<MediaPlayerInfo> list = {info}; EXPECT_CALL(interface, GetMediaPlayerList(_)) .WillRepeatedly(InvokeCb<0>(0, list)); auto set_addr_player_rej_rsp = RejectBuilder::MakeBuilder( CommandPdu::SET_ADDRESSED_PLAYER, Status::INVALID_PLAYER_ID); EXPECT_CALL(response_cb, Call(1, false, matchPacket(std::move(set_addr_player_rej_rsp)))) .Times(1); auto player_id_1_request = TestAvrcpPacket::Make(set_addressed_player_id_1_request); SendMessage(1, player_id_1_request); auto set_addr_player_rsp = SetAddressedPlayerResponseBuilder::MakeBuilder(Status::NO_ERROR); EXPECT_CALL(response_cb, Call(1, false, matchPacket(std::move(set_addr_player_rsp)))) .Times(1); Loading