Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c3c10180 authored by Étienne Ruffieux (xWF)'s avatar Étienne Ruffieux (xWF) Committed by Automerger Merge Worker
Browse files

Merge "Add Attribute response for GetElementAttributes" into main am: 01f739fa am: 1f67179e

parents 27d1e9f7 1f67179e
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -116,8 +116,13 @@ cc_fuzz {
        "packages/modules/Bluetooth/system/packet/tests",
        "packages/modules/Bluetooth/system/stack/include",
    ],
    shared_libs: [
        "libaconfig_storage_read_api_cc",
        "server_configurable_flags",
    ],
    static_libs: [
        "avrcp-target-service",
        "bluetooth_flags_c_lib",
        "lib-bt-packets",
        "lib-bt-packets-avrcp",
        "lib-bt-packets-base",
+26 −4
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
#include "device.h"

#include <bluetooth/log.h>
#include <com_android_bluetooth_flags.h>

#include "abstract_message_loop.h"
#include "avrcp_common.h"
@@ -776,9 +777,30 @@ void Device::GetElementAttributesResponse(uint8_t label,
      }
    }
  } else {  // zero attributes requested which means all attributes requested

    if (!com::android::bluetooth::flags::get_all_element_attributes_empty()) {
      for (const auto& attribute : info.attributes) {
        response->AddAttributeEntry(attribute);
      }
    } else {
      std::vector<Attribute> all_attributes = {Attribute::TITLE,
                                               Attribute::ARTIST_NAME,
                                               Attribute::ALBUM_NAME,
                                               Attribute::TRACK_NUMBER,
                                               Attribute::TOTAL_NUMBER_OF_TRACKS,
                                               Attribute::GENRE,
                                               Attribute::PLAYING_TIME,
                                               Attribute::DEFAULT_COVER_ART};
      for (const auto& attribute : all_attributes) {
        if (info.attributes.find(attribute) != info.attributes.end()) {
          response->AddAttributeEntry(*info.attributes.find(attribute));
        } else {
          // If all attributes were requested, we send a response even for attributes that we don't
          // have a value for.
          response->AddAttributeEntry(attribute, std::string());
        }
      }
    }
  }

  send_message(label, false, std::move(response));
@@ -1402,7 +1424,7 @@ void Device::GetVFSListResponse(uint8_t label, std::shared_ptr<GetFolderItemsReq

      auto title = song.attributes.find(Attribute::TITLE) != song.attributes.end()
                           ? song.attributes.find(Attribute::TITLE)->value()
                           : "No Song Info";
                           : std::string();
      MediaElementItem song_item(vfs_ids_.get_uid(song.media_id), title,
                                 std::set<AttributeEntry>());

@@ -1445,7 +1467,7 @@ void Device::GetNowPlayingListResponse(uint8_t label, std::shared_ptr<GetFolderI

    auto title = song.attributes.find(Attribute::TITLE) != song.attributes.end()
                         ? song.attributes.find(Attribute::TITLE)->value()
                         : "No Song Info";
                         : std::string();

    MediaElementItem item(i + 1, title, std::set<AttributeEntry>());
    if (pkt->GetNumAttributes() == 0x00) {