0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
0x00, 0x05, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x07};
+// AVRCP Get Item Attributes request with all attributes requested
+// with the following fields:
+// scope = 0x03 (Now Playing List)
+// uid_counter = 0x0001
+// uid = 0x0000000000000001
+std::vector<uint8_t> get_item_attributes_request_all_attributes_invalid = {
+ 0x73, 0x00, 0x28, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x01, 0x07, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
+ 0x00, 0x05, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x07};
+
// AVRCP Get Item Attributes Response with the following attributes:
// title = "Test Song"
// artist = "Test Artist"
void Device::HandleGetItemAttributes(
uint8_t label, std::shared_ptr<GetItemAttributesRequest> pkt) {
DEVICE_VLOG(2) << __func__ << ": scope=" << pkt->GetScope()
- << " uid=" << loghex(pkt->GetUid());
+ << " uid=" << loghex(pkt->GetUid())
+ << " uid counter=" << loghex(pkt->GetUidCounter());
+ if (pkt->GetUidCounter() != 0x0000) { // For database unaware player, use 0
+ DEVICE_LOG(WARNING) << "UidCounter is invalid";
+ auto builder = GetItemAttributesResponseBuilder::MakeBuilder(
+ Status::UIDS_CHANGED, browse_mtu_);
+ send_message(label, true, std::move(builder));
+ return;
+ }
switch (pkt->GetScope()) {
case Scope::NOW_PLAYING: {
media_interface_->GetNowPlayingList(
SendMessage(3, request_unknown);
}
+TEST_F(AvrcpDeviceTest, getInvalidItemAttributesTest) {
+ MockMediaInterface interface;
+ NiceMock<MockA2dpInterface> a2dp_interface;
+
+ test_device->RegisterInterfaces(&interface, &a2dp_interface, nullptr);
+
+ SongInfo info = {"test_id",
+ {// The attribute map
+ AttributeEntry(Attribute::TITLE, "Test Song"),
+ AttributeEntry(Attribute::ARTIST_NAME, "Test Artist"),
+ AttributeEntry(Attribute::ALBUM_NAME, "Test Album"),
+ AttributeEntry(Attribute::TRACK_NUMBER, "1"),
+ AttributeEntry(Attribute::TOTAL_NUMBER_OF_TRACKS, "2"),
+ AttributeEntry(Attribute::GENRE, "Test Genre"),
+ AttributeEntry(Attribute::PLAYING_TIME, "1000")}};
+ std::vector<SongInfo> list = {info};
+
+ EXPECT_CALL(interface, GetNowPlayingList(_))
+ .WillRepeatedly(InvokeCb<0>("test_id", list));
+
+ auto compare_to_full = GetItemAttributesResponseBuilder::MakeBuilder(
+ Status::UIDS_CHANGED, 0xFFFF);
+ compare_to_full->AddAttributeEntry(Attribute::TITLE, "Test Song");
+ compare_to_full->AddAttributeEntry(Attribute::ARTIST_NAME, "Test Artist");
+ compare_to_full->AddAttributeEntry(Attribute::ALBUM_NAME, "Test Album");
+ compare_to_full->AddAttributeEntry(Attribute::TRACK_NUMBER, "1");
+ compare_to_full->AddAttributeEntry(Attribute::TOTAL_NUMBER_OF_TRACKS, "2");
+ compare_to_full->AddAttributeEntry(Attribute::GENRE, "Test Genre");
+ compare_to_full->AddAttributeEntry(Attribute::PLAYING_TIME, "1000");
+ EXPECT_CALL(response_cb,
+ Call(1, true, matchPacket(std::move(compare_to_full))))
+ .Times(1);
+
+ auto request = TestBrowsePacket::Make(
+ get_item_attributes_request_all_attributes_invalid);
+ SendBrowseMessage(1, request);
+}
+
} // namespace avrcp
} // namespace bluetooth