Remove btif_rc_check_handle_pending_play

The current logic prevents rc_pending_play from ever
being set to true. Thus this method is always void.

Bug: 331817295
Test: m com.android.bt
Flag: EXEMPT, dead code removal
Change-Id: I26cf7b61dcf2e889c22220a2eca77fbbfdb823f5
diff --git a/system/btif/include/btif_rc.h b/system/btif/include/btif_rc.h
index 27454bc..56ab64b 100644
--- a/system/btif/include/btif_rc.h
+++ b/system/btif/include/btif_rc.h
@@ -26,7 +26,6 @@
 
 void btif_rc_handler(tBTA_AV_EVT event, tBTA_AV* p_data);
 uint8_t btif_rc_get_connected_peer_handle(const RawAddress& peer_addr);
-void btif_rc_check_handle_pending_play(const RawAddress& peer_addr, bool bSendToApp);
 bool btif_rc_is_connected_peer(const RawAddress& peer_addr);
 void btif_rc_check_pending_cmd(const RawAddress& peer_addr);
 void btif_rc_get_addr_by_handle(uint8_t handle, RawAddress& rc_addr);
diff --git a/system/btif/src/btif_av.cc b/system/btif/src/btif_av.cc
index 278c4f6..e4f784a 100644
--- a/system/btif/src/btif_av.cc
+++ b/system/btif/src/btif_av.cc
@@ -1889,11 +1889,7 @@
                                        peer_.IsSource() ? A2dpType::kSink : A2dpType::kSource);
           peer_.StateMachine().TransitionTo(BtifAvStateMachine::kStateIdle);
         } else {
-          if (peer_.IsSink()) {
-            // If queued PLAY command, send it now
-            btif_rc_check_handle_pending_play(p_bta_data->open.bd_addr,
-                                              (p_bta_data->open.status == BTA_AV_SUCCESS));
-          } else if (peer_.IsSource() && (p_bta_data->open.status == BTA_AV_SUCCESS)) {
+          if (peer_.IsSource() && (p_bta_data->open.status == BTA_AV_SUCCESS)) {
             // Bring up AVRCP connection as well
             BTA_AvOpenRc(peer_.BtaHandle());
           }
@@ -2109,11 +2105,7 @@
 
       // Change state to Open/Idle based on the status
       peer_.StateMachine().TransitionTo(av_state);
-      if (peer_.IsSink()) {
-        // If queued PLAY command, send it now
-        btif_rc_check_handle_pending_play(p_bta_data->open.bd_addr,
-                                          (p_bta_data->open.status == BTA_AV_SUCCESS));
-      } else if (peer_.IsSource() && (p_bta_data->open.status == BTA_AV_SUCCESS)) {
+      if (peer_.IsSource() && (p_bta_data->open.status == BTA_AV_SUCCESS)) {
         // Bring up AVRCP connection as well
         if (btif_av_src_sink_coexist_enabled() &&
             btif_av_sink.AllowedToConnect(peer_.PeerAddress())) {
diff --git a/system/btif/src/btif_rc.cc b/system/btif/src/btif_rc.cc
index e6623f2..dba7b41 100644
--- a/system/btif/src/btif_rc.cc
+++ b/system/btif/src/btif_rc.cc
@@ -207,7 +207,6 @@
   uint16_t rc_cover_art_psm;  // AVRCP-BIP psm
   btrc_connection_state_t rc_state;
   RawAddress rc_addr;
-  uint16_t rc_pending_play;
   btif_rc_cmd_ctxt_t rc_pdu_info[MAX_CMD_QUEUE_LEN];
   btif_rc_reg_notifications_t rc_notif[MAX_RC_NOTIFICATIONS];
   unsigned int rc_volume;
@@ -237,8 +236,6 @@
   uint8_t handle;
 } btif_rc_handle_t;
 
-static void sleep_ms(uint64_t timeout_ms);
-
 /* Response status code - Unknown Error - this is changed to "reserved" */
 #define BTIF_STS_GEN_ERROR 0x06
 
@@ -404,7 +401,6 @@
   p_dev->rc_cover_art_psm = 0;
   p_dev->rc_state = BTRC_CONNECTION_STATE_DISCONNECTED;
   p_dev->rc_addr = RawAddress::kEmpty;
-  p_dev->rc_pending_play = false;
   for (int i = 0; i < MAX_CMD_QUEUE_LEN; ++i) {
     p_dev->rc_pdu_info[i].ctype = 0;
     p_dev->rc_pdu_info[i].label = 0;
@@ -791,58 +787,6 @@
 }
 
 /***************************************************************************
- *  Function       handle_rc_passthrough_cmd
- *
- *  - Argument:    tBTA_AV_RC rc_id   remote control command ID
- *                 tBTA_AV_STATE key_state status of key press
- *
- *  - Description: Remote control command handler
- *
- ***************************************************************************/
-static void handle_rc_passthrough_cmd(tBTA_AV_REMOTE_CMD* p_remote_cmd) {
-  if (p_remote_cmd == NULL) {
-    log::error("No remote command!");
-    return;
-  }
-
-  btif_rc_device_cb_t* p_dev = btif_rc_get_device_by_handle(p_remote_cmd->rc_handle);
-  if (p_dev == NULL) {
-    log::error("Got passthrough command from invalid rc handle");
-    return;
-  }
-
-  log::verbose("p_remote_cmd->rc_id: {}", p_remote_cmd->rc_id);
-
-  /* If AVRC is open and peer sends PLAY but there is no AVDT, then we queue-up
-   * this PLAY */
-  if ((p_remote_cmd->rc_id == AVRC_ID_PLAY) && (!btif_av_is_connected(A2dpType::kSink))) {
-    if (p_remote_cmd->key_state == AVRC_STATE_PRESS) {
-      log::warn("AVDT not open, queuing the PLAY command");
-      p_dev->rc_pending_play = true;
-    }
-    return;
-  }
-
-  /* If we previously queued a play and we get a PAUSE, clear it. */
-  if ((p_remote_cmd->rc_id == AVRC_ID_PAUSE) && (p_dev->rc_pending_play)) {
-    log::warn("Clear the pending PLAY on PAUSE received");
-    p_dev->rc_pending_play = false;
-    return;
-  }
-
-  if ((p_remote_cmd->rc_id == AVRC_ID_STOP) && (!btif_av_stream_started_ready(A2dpType::kSink))) {
-    log::warn("Stream suspended, ignore STOP cmd");
-    return;
-  }
-
-  int pressed = (p_remote_cmd->key_state == AVRC_STATE_PRESS) ? 1 : 0;
-
-  /* pass all commands up */
-  log::verbose("rc_features: {}, cmd->rc_id: {}, pressed: {}", p_dev->rc_features,
-               p_remote_cmd->rc_id, pressed);
-}
-
-/***************************************************************************
  *  Function       handle_rc_passthrough_rsp
  *
  *  - Argument:    tBTA_AV_REMOTE_RSP passthrough command response
@@ -1070,55 +1014,6 @@
   return p_dev->rc_handle;
 }
 
-/***************************************************************************
- **
- ** Function       btif_rc_check_handle_pending_play
- **
- ** Description    Clears the queued PLAY command. if |bSendToApp| is true,
- **                forwards to app
- **
- ***************************************************************************/
-
-/* clear the queued PLAY command. if |bSendToApp| is true, forward to app */
-void btif_rc_check_handle_pending_play(const RawAddress& peer_addr, bool bSendToApp) {
-  btif_rc_device_cb_t* p_dev = NULL;
-  p_dev = btif_rc_get_device_by_bda(peer_addr);
-
-  if (p_dev == NULL) {
-    log::error("p_dev NULL");
-    return;
-  }
-
-  log::verbose("bSendToApp: {}", bSendToApp);
-  if (p_dev->rc_pending_play) {
-    if (bSendToApp) {
-      tBTA_AV_REMOTE_CMD remote_cmd;
-      log::verbose("Sending queued PLAYED event to app");
-
-      memset(&remote_cmd, 0, sizeof(tBTA_AV_REMOTE_CMD));
-      remote_cmd.rc_handle = p_dev->rc_handle;
-      remote_cmd.rc_id = AVRC_ID_PLAY;
-      remote_cmd.hdr.ctype = AVRC_CMD_CTRL;
-      remote_cmd.hdr.opcode = AVRC_OP_PASS_THRU;
-
-      /* delay sending to app, else there is a timing issue in the framework,
-       ** which causes the audio to be on th device's speaker. Delay between
-       ** OPEN & RC_PLAYs
-       */
-      sleep_ms(200);
-      /* send to app - both PRESSED & RELEASED */
-      remote_cmd.key_state = AVRC_STATE_PRESS;
-      handle_rc_passthrough_cmd(&remote_cmd);
-
-      sleep_ms(100);
-
-      remote_cmd.key_state = AVRC_STATE_RELEASE;
-      handle_rc_passthrough_cmd(&remote_cmd);
-    }
-    p_dev->rc_pending_play = false;
-  }
-}
-
 /* Generic reject response */
 static void send_reject_response(uint8_t rc_handle, uint8_t label, uint8_t pdu, uint8_t status,
                                  uint8_t opcode) {
@@ -3875,22 +3770,6 @@
 }
 
 /*******************************************************************************
- *      Function       sleep_ms
- *
- *      Description    Sleep the calling thread unconditionally for
- *                     |timeout_ms| milliseconds.
- *
- *      Returns        void
- ******************************************************************************/
-static void sleep_ms(uint64_t timeout_ms) {
-  struct timespec delay;
-  delay.tv_sec = timeout_ms / 1000;
-  delay.tv_nsec = 1000 * 1000 * (timeout_ms % 1000);
-
-  OSI_NO_INTR(nanosleep(&delay, &delay));
-}
-
-/*******************************************************************************
  *      Function       btif_debug_rc_dump
  *
  *      Description    Dumps the state of the btif_rc subsytem
diff --git a/system/btif/test/btif_rc_test.cc b/system/btif/test/btif_rc_test.cc
index 88b1a2c..b537e06 100644
--- a/system/btif/test/btif_rc_test.cc
+++ b/system/btif/test/btif_rc_test.cc
@@ -413,7 +413,6 @@
   btif_rc_cb.rc_multi_cb[0].rc_cover_art_psm = 0;
   btif_rc_cb.rc_multi_cb[0].rc_state = BTRC_CONNECTION_STATE_CONNECTED;
   btif_rc_cb.rc_multi_cb[0].rc_addr = kDeviceAddress;
-  btif_rc_cb.rc_multi_cb[0].rc_pending_play = 0;
   btif_rc_cb.rc_multi_cb[0].rc_volume = 0;
   btif_rc_cb.rc_multi_cb[0].rc_vol_label = 0;
   btif_rc_cb.rc_multi_cb[0].rc_supported_event_list = nullptr;