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

Commit e3d6c4db authored by tedwang's avatar tedwang Committed by android-build-merger
Browse files

Merge changes from topic "avrcp-addressed-player-changed"

am: 75979011

Change-Id: I0a1fe4ac30fe95b6d86ebaac1cc8456e9b721c2c
parents d1c71581 75979011
Loading
Loading
Loading
Loading
+51 −8
Original line number Original line Diff line number Diff line
@@ -234,7 +234,7 @@ void Device::HandleNotification(
      addr_player_changed_ = Notification(true, label);
      addr_player_changed_ = Notification(true, label);
      media_interface_->GetMediaPlayerList(
      media_interface_->GetMediaPlayerList(
          base::Bind(&Device::AddressedPlayerNotificationResponse,
          base::Bind(&Device::AddressedPlayerNotificationResponse,
                     weak_ptr_factory_.GetWeakPtr(), label, false));
                     weak_ptr_factory_.GetWeakPtr(), label, true));
    } break;
    } break;


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


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


  if (!interim) {
  if (!interim) {
    active_labels_.erase(label);
    active_labels_.erase(label);
    addr_player_changed_ = Notification(false, 0);
    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__;
  DEVICE_VLOG(4) << __func__;


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


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

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


void Device::HandleTrackUpdate() {
void Device::HandleTrackUpdate() {
@@ -1185,6 +1197,37 @@ void Device::HandlePlayPosUpdate() {
      play_pos_changed_.second, false));
      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() {
void Device::DeviceDisconnected() {
  DEVICE_LOG(INFO) << "Device was disconnected";
  DEVICE_LOG(INFO) << "Device was disconnected";
  play_pos_update_cb_.Cancel();
  play_pos_update_cb_.Cancel();
+5 −0
Original line number Original line Diff line number Diff line
@@ -160,7 +160,12 @@ class Device {
      uint8_t label, std::shared_ptr<GetElementAttributesRequest> pkt,
      uint8_t label, std::shared_ptr<GetElementAttributesRequest> pkt,
      SongInfo info);
      SongInfo info);


  // AVAILABLE PLAYER CHANGED
  virtual void HandleAvailablePlayerUpdate();

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