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

Commit 59561bbe authored by tedwang's avatar tedwang Committed by Hansong Zhang
Browse files

Send addressed and available player change for PTS test

Implement HandleAddressPlayerUpdate() and HandAvailablePlayerUpdate()
for PTS test.

Bug: 79375787 79376305
Test: PTS Test AVRCPTG/MPS/BV-05-C AVRCP/TG/MPS/BV-07-C
Change-Id: I6b976af8bdd1afcc9799c50c8e558939cf7be187
Merged-In: I6b976af8bdd1afcc9799c50c8e558939cf7be187
(cherry picked from commit 028c9c14)
parent 8c19c135
Loading
Loading
Loading
Loading
+51 −8
Original line number Diff line number Diff line
@@ -234,7 +234,7 @@ void Device::HandleNotification(
      addr_player_changed_ = Notification(true, label);
      media_interface_->GetMediaPlayerList(
          base::Bind(&Device::AddressedPlayerNotificationResponse,
                     weak_ptr_factory_.GetWeakPtr(), label, false));
                     weak_ptr_factory_.GetWeakPtr(), label, true));
    } break;

    case Event::UIDS_CHANGED: {
@@ -472,12 +472,28 @@ void Device::AddressedPlayerNotificationResponse(

  auto response =
      RegisterNotificationResponseBuilder::MakeAddressedPlayerBuilder(
          true, curr_player, 0x0000);
          interim, curr_player, 0x0000);
  send_message_cb_.Run(label, false, std::move(response));

  if (!interim) {
    active_labels_.erase(label);
    addr_player_changed_ = Notification(false, 0);
    RejectNotification();
  }
}

void Device::RejectNotification() {
  DEVICE_VLOG(1) << __func__;
  Notification* rejectNotification[] = {&play_status_changed_, &track_changed_,
                                        &play_pos_changed_,
                                        &now_playing_changed_};
  for (int i = 0; i < 4; i++) {
    uint8_t label = rejectNotification[i]->second;
    auto response = RejectBuilder::MakeBuilder(
        CommandPdu::REGISTER_NOTIFICATION, Status::ADDRESSED_PLAYER_CHANGED);
    send_message_cb_.Run(label, false, std::move(response));
    active_labels_.erase(label);
    rejectNotification[i] = new Notification(false, 0);
  }
}

@@ -1101,16 +1117,12 @@ void Device::SendFolderUpdate(bool available_players, bool addressed_player,
  DEVICE_VLOG(4) << __func__;

  if (available_players) {
    // TODO (apanicke): Right now this isn't needed since we only show one
    // player. Implement this in the future for a more complete
    // implementation though.
    HandleAvailablePlayerUpdate();
  }

  if (addressed_player) {
    // TODO (apanicke): See above TODO.
    HandleAddressedPlayerUpdate();
  }

  CHECK(false) << "NEED TO IMPLEMENT";
}

void Device::HandleTrackUpdate() {
@@ -1185,6 +1197,37 @@ void Device::HandlePlayPosUpdate() {
      play_pos_changed_.second, false));
}

void Device::HandleAvailablePlayerUpdate() {
  DEVICE_VLOG(1) << __func__;

  if (!avail_players_changed_.first) {
    LOG(WARNING) << "Device is not registered for available player updates";
    return;
  }

  auto response =
      RegisterNotificationResponseBuilder::MakeAvailablePlayersBuilder(false);
  send_message_cb_.Run(avail_players_changed_.second, false,
                       std::move(response));

  if (!avail_players_changed_.first) {
    active_labels_.erase(avail_players_changed_.second);
    avail_players_changed_ = Notification(false, 0);
  }
}

void Device::HandleAddressedPlayerUpdate() {
  DEVICE_VLOG(1) << __func__;
  if (!addr_player_changed_.first) {
    DEVICE_LOG(WARNING)
        << "Device is not registered for addressed player updates";
    return;
  }
  media_interface_->GetMediaPlayerList(base::Bind(
      &Device::AddressedPlayerNotificationResponse,
      weak_ptr_factory_.GetWeakPtr(), addr_player_changed_.second, false));
}

void Device::DeviceDisconnected() {
  DEVICE_LOG(INFO) << "Device was disconnected";
  play_pos_update_cb_.Cancel();
+5 −0
Original line number Diff line number Diff line
@@ -160,7 +160,12 @@ class Device {
      uint8_t label, std::shared_ptr<GetElementAttributesRequest> pkt,
      SongInfo info);

  // AVAILABLE PLAYER CHANGED
  virtual void HandleAvailablePlayerUpdate();

  // ADDRESSED PLAYER CHANGED
  virtual void HandleAddressedPlayerUpdate();
  virtual void RejectNotification();
  virtual void AddressedPlayerNotificationResponse(
      uint8_t label, bool interim, uint16_t curr_player,
      std::vector<MediaPlayerInfo> /* unused */);