OSDN Git Service

AVDTP: static IOP database for AVDTP SUSPEND
authorCheney Ni <cheneyni@google.com>
Wed, 27 Jan 2021 08:55:51 +0000 (16:55 +0800)
committerCheney Ni <cheneyni@google.com>
Wed, 27 Jan 2021 09:18:52 +0000 (17:18 +0800)
The stack marked a device as AVDTP SUSPEND unsupported if any runtime
failure was detected while suspending. It would keep streaming without
sending a SUSPEND command next time, but caused more issues like SCO
failure. Here is instructing a static IOP database to replace that old
detection, and suppose those issue devices will be fewer day by day.

Bug: 177101308
Tag: #refactor
Test: Add a device to database and check if not sending AVDTP SUSPEND
Change-Id: Id37902be88a285e9809f5bdc766757cb8323f2c2

bta/av/bta_av_aact.cc
device/include/interop.h
device/src/interop.cc

index c2c8489..9f52b71 100644 (file)
@@ -1147,6 +1147,7 @@ void bta_av_setconfig_rsp(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) {
  ******************************************************************************/
 void bta_av_str_opened(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) {
   tBTA_AV_CONN_CHG msg;
+  char remote_name[BTM_MAX_REM_BD_NAME_LEN] = "";
   uint8_t* p;
 
   APPL_TRACE_DEBUG("%s: peer %s bta_handle: 0x%x", __func__,
@@ -1160,6 +1161,15 @@ void bta_av_str_opened(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) {
   /* set the congestion flag, so AV would not send media packets by accident */
   p_scb->cong = true;
   p_scb->offload_start_pending = false;
+  // Don't use AVDTP SUSPEND for restrict listed devices
+  btif_storage_get_stored_remote_name(p_scb->PeerAddress(), remote_name);
+  if (interop_match_name(INTEROP_DISABLE_AVDTP_SUSPEND, remote_name) ||
+      interop_match_addr(INTEROP_DISABLE_AVDTP_SUSPEND,
+                         &p_scb->PeerAddress())) {
+    LOG_INFO("%s: disable AVDTP SUSPEND: interop matched name %s address %s",
+             __func__, remote_name, p_scb->PeerAddress().ToString().c_str());
+    p_scb->suspend_sup = false;
+  }
 
   p_scb->stream_mtu =
       p_data->str_msg.msg.open_ind.peer_mtu - AVDT_MEDIA_HDR_SIZE;
@@ -2467,10 +2477,6 @@ void bta_av_suspend_cfm(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) {
 
   suspend_rsp.status = BTA_AV_SUCCESS;
   if (err_code && (err_code != AVDT_ERR_BAD_STATE)) {
-    /* Disable suspend feature only with explicit rejection(not with timeout) */
-    if (err_code != AVDT_ERR_TIMEOUT) {
-      p_scb->suspend_sup = false;
-    }
     suspend_rsp.status = BTA_AV_FAIL;
 
     APPL_TRACE_ERROR("%s: suspend failed, closing connection", __func__);
@@ -2684,11 +2690,6 @@ void bta_av_suspend_cont(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) {
       bta_av_ssm_execute(p_scb, BTA_AV_STR_DISC_FAIL_EVT, NULL);
     } else {
       APPL_TRACE_ERROR("%s: suspend rejected, try close", __func__);
-      /* Disable suspend feature only with explicit rejection(not with timeout)
-       */
-      if (err_code != AVDT_ERR_TIMEOUT) {
-        p_scb->suspend_sup = false;
-      }
       /* drop the buffers queued in L2CAP */
       L2CA_FlushChannel(p_scb->l2c_cid, L2CAP_FLUSH_CHANS_ALL);
 
index efbafa1..e1f93d4 100644 (file)
@@ -107,7 +107,11 @@ typedef enum {
   // Disable sniff mode for headsets/car-kits
   // Some car kits supports sniff mode but when DUT initiates sniff req
   // Remote will go to bad state and its leads to LMP time out.
-  INTEROP_DISABLE_SNIFF
+  INTEROP_DISABLE_SNIFF,
+
+  // Do not send AVDTP SUSPEND while the playback is paused.
+  // Some older A2DP Sink devices might not support to pause the streaming.
+  INTEROP_DISABLE_AVDTP_SUSPEND
 } interop_feature_t;
 
 // Check if a given |addr| matches a known interoperability workaround as
index 773e413..e9e9da9 100644 (file)
@@ -133,6 +133,7 @@ static const char* interop_feature_string_(const interop_feature_t feature) {
     CASE_RETURN_STR(INTEROP_DISABLE_NAME_REQUEST)
     CASE_RETURN_STR(INTEROP_AVRCP_1_4_ONLY)
     CASE_RETURN_STR(INTEROP_DISABLE_SNIFF)
+    CASE_RETURN_STR(INTEROP_DISABLE_AVDTP_SUSPEND)
   }
 
   return "UNKNOWN";