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

Commit c3b14ee2 authored by Ajay Panicker's avatar Ajay Panicker
Browse files

Persist VFS ID's between directory changes.

Some carkits don't honor the fact that VFS ID's only are consistent to
the folder they are currently browsing. Now a UID will remain valid
until the connection ends.

Bug: 68812037
Test: Run net_test_avrcp
Change-Id: I67898277327b54eaeca2121b9ff173b22bd4ba71
parent c7353aa0
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -84,5 +84,29 @@ std::string ChangePathRequest::ToString() const {
  return ss.str();
}

std::unique_ptr<ChangePathRequestBuilder> ChangePathRequestBuilder::MakeBuilder(
    uint16_t uid_counter, Direction direction, uint64_t folder_uid) {
  std::unique_ptr<ChangePathRequestBuilder> builder(
      new ChangePathRequestBuilder(uid_counter, direction, folder_uid));

  return builder;
}

size_t ChangePathRequestBuilder::size() const {
  return ChangePathRequest::kMinSize();
}

bool ChangePathRequestBuilder::Serialize(
    const std::shared_ptr<::bluetooth::Packet>& pkt) {
  ReserveSpace(pkt, size());

  BrowsePacketBuilder::PushHeader(pkt, size() - BrowsePacket::kMinSize());

  AddPayloadOctets2(pkt, base::ByteSwap(uid_counter_));
  AddPayloadOctets1(pkt, static_cast<uint8_t>(direction_));
  AddPayloadOctets8(pkt, base::ByteSwap(folder_uid_));
  return true;
}

}  // namespace avrcp
}  // namespace bluetooth
 No newline at end of file
+24 −0
Original line number Diff line number Diff line
@@ -69,5 +69,29 @@ class ChangePathRequest : public BrowsePacket {
  using BrowsePacket::BrowsePacket;
};

class ChangePathRequestBuilder : public BrowsePacketBuilder {
 public:
  virtual ~ChangePathRequestBuilder() = default;

  static std::unique_ptr<ChangePathRequestBuilder> MakeBuilder(
      uint16_t uid_counter, Direction direction, uint64_t folder_uid);

  virtual size_t size() const override;
  virtual bool Serialize(
      const std::shared_ptr<::bluetooth::Packet>& pkt) override;

 private:
  ChangePathRequestBuilder(uint16_t uid_counter, Direction direction,
                           uint64_t folder_uid)
      : BrowsePacketBuilder(BrowsePdu::CHANGE_PATH),
        uid_counter_(uid_counter),
        direction_(direction),
        folder_uid_(folder_uid){};

  uint16_t uid_counter_;
  Direction direction_;
  uint64_t folder_uid_;
};

}  // namespace avrcp
}  // namespace bluetooth
 No newline at end of file
+40 −0
Original line number Diff line number Diff line
@@ -301,5 +301,45 @@ std::string GetFolderItemsRequest::ToString() const {
  return ss.str();
}

std::unique_ptr<GetFolderItemsRequestBuilder>
GetFolderItemsRequestBuilder::MakeBuilder(
    Scope scope, uint32_t start_item, uint32_t end_item,
    const std::set<Attribute>& requested_attrs) {
  std::unique_ptr<GetFolderItemsRequestBuilder> builder(
      new GetFolderItemsRequestBuilder(scope, start_item, end_item,
                                       requested_attrs));

  return builder;
}

size_t GetFolderItemsRequestBuilder::size() const {
  size_t len = GetFolderItemsRequest::kMinSize();
  len += requested_attrs_.size() * sizeof(Attribute);
  return len;
}

bool GetFolderItemsRequestBuilder::Serialize(
    const std::shared_ptr<::bluetooth::Packet>& pkt) {
  ReserveSpace(pkt, size());

  BrowsePacketBuilder::PushHeader(pkt, size() - BrowsePacket::kMinSize());

  AddPayloadOctets1(pkt, static_cast<uint8_t>(scope_));
  AddPayloadOctets4(pkt, base::ByteSwap(start_item_));
  AddPayloadOctets4(pkt, base::ByteSwap(end_item_));

  if (requested_attrs_.size() == 0) {
    // 0xFF is the value to signify that there are no attributes requested.
    AddPayloadOctets1(pkt, 0xFF);
    return true;
  }

  AddPayloadOctets1(pkt, requested_attrs_.size());
  for (const auto& attr : requested_attrs_) {
    AddPayloadOctets4(pkt, base::ByteSwap(static_cast<uint32_t>(attr)));
  }
  return true;
}

}  // namespace avrcp
}  // namespace bluetooth
 No newline at end of file
+28 −0
Original line number Diff line number Diff line
@@ -97,5 +97,33 @@ class GetFolderItemsRequest : public BrowsePacket {
  using BrowsePacket::BrowsePacket;
};

class GetFolderItemsRequestBuilder : public BrowsePacketBuilder {
 public:
  virtual ~GetFolderItemsRequestBuilder() = default;

  static std::unique_ptr<GetFolderItemsRequestBuilder> MakeBuilder(
      Scope scope, uint32_t start_item, uint32_t end_item,
      const std::set<Attribute>& requested_attrs);

  virtual size_t size() const override;
  virtual bool Serialize(
      const std::shared_ptr<::bluetooth::Packet>& pkt) override;

 protected:
  GetFolderItemsRequestBuilder(Scope scope, uint32_t start_item,
                               uint32_t end_item,
                               const std::set<Attribute>& requested_attrs)
      : BrowsePacketBuilder(BrowsePdu::GET_FOLDER_ITEMS),
        scope_(scope),
        start_item_(start_item),
        end_item_(end_item),
        requested_attrs_(requested_attrs){};

  Scope scope_;
  uint32_t start_item_;
  uint32_t end_item_;
  std::set<Attribute> requested_attrs_;
};

}  // namespace avrcp
}  // namespace bluetooth
 No newline at end of file
+21 −1
Original line number Diff line number Diff line
@@ -147,11 +147,31 @@ std::vector<uint8_t> reject_player_app_settings_response = {
//    scope = 0x00 (Media Player List)
//    start_item = 0x00
//    end_item = 0x03
//    attributes_requested: none
//    attributes_requested: all
std::vector<uint8_t> get_folder_items_request = {0x71, 0x00, 0x0a, 0x00, 0x00,
                                                 0x00, 0x00, 0x00, 0x00, 0x00,
                                                 0x00, 0x03, 0x00};

// AVRCP Browse Get Folder Items Request packet for media players with
// the following data:
//    scope = 0x01 (VFS)
//    start_item = 0x00
//    end_item = 0x09
//    attributes_requested: none
std::vector<uint8_t> get_folder_items_request_no_attrs = {
    0x71, 0x00, 0x0a, 0x01, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x09, 0xff};

// AVRCP Browse Get Folder Items Request packet for media players with
// the following data:
//    scope = 0x01 (VFS)
//    start_item = 0x00
//    end_item = 0x09
//    attributes_requested: Title
std::vector<uint8_t> get_folder_items_request_title = {
    0x71, 0x00, 0x0e, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x09, 0x01, 0x00, 0x00, 0x00, 0x1};

// AVRCP Browse Get Folder Items Request packet for vfs with
// the following data:
//    scope = 0x01 (VFS)
Loading