Use the correct AVDTP version-specific features

Failure:
A2DP is not reconnected after power cycling DUT BT.

Root cause:
AVDTP v1.3 feature request (AVDT_GetAllCapReq) sent by DUT
as remote supports the same, but this 1.3 feature is not
completely supported by DUT which leads to erroneous behavior.

Fix:
Use AVDT_GetAllCapReq request only when both host and remote
AVDTP version are 1.3 and above.

Test: 1.Pair to CarKit; 2.Connect to CarKit; 3.Do BT power cycle @ DUT
Bug: 35657623
Change-Id: I66c2d7d8fe8506b74282bcca93595e1cbf5c2565
(cherry picked from commit 9cd9ef4c3818d2c7949f52703b3c2ba0e0f43f2f)
diff --git a/system/bta/av/bta_av_aact.cc b/system/bta/av/bta_av_aact.cc
index acc4c2c..2b94e2b 100644
--- a/system/bta/av/bta_av_aact.cc
+++ b/system/bta/av/bta_av_aact.cc
@@ -387,7 +387,8 @@
       /* we got a stream; get its capabilities */
       if (p_scb->p_cap == NULL)
         p_scb->p_cap = (tAVDT_CFG*)osi_malloc(sizeof(tAVDT_CFG));
-      if (p_scb->avdt_version >= AVDT_VERSION_SYNC) {
+      if ((p_scb->avdt_version >= AVDT_VERSION_1_3) &&
+          (A2DP_GetAvdtpVersion() >= AVDT_VERSION_1_3)) {
         p_req = AVDT_GetAllCapReq;
       } else {
         p_req = AVDT_GetCapReq;
@@ -1264,7 +1265,7 @@
     p_scb->num_seps = num;
 
     if (p_scb->cur_psc_mask & AVDT_PSC_DELAY_RPT)
-      p_scb->avdt_version = AVDT_VERSION_SYNC;
+      p_scb->avdt_version = AVDT_VERSION_1_3;
 
     if (A2DP_GetCodecType(p_scb->cfg.codec_info) == A2DP_MEDIA_CT_SBC ||
         num > 1) {
diff --git a/system/stack/a2dp/a2dp_api.cc b/system/stack/a2dp/a2dp_api.cc
index a52924a..11d3bf2 100644
--- a/system/stack/a2dp/a2dp_api.cc
+++ b/system/stack/a2dp/a2dp_api.cc
@@ -377,3 +377,5 @@
   a2dp_cb.trace_level = BT_TRACE_LEVEL_NONE;
 #endif
 }
+
+uint16_t A2DP_GetAvdtpVersion() { return a2dp_cb.avdt_sdp_ver; }
diff --git a/system/stack/include/a2dp_api.h b/system/stack/include/a2dp_api.h
index c4ab737..15d30d8 100644
--- a/system/stack/include/a2dp_api.h
+++ b/system/stack/include/a2dp_api.h
@@ -162,6 +162,17 @@
 
 /******************************************************************************
  *
+ * Function         A2DP_GetAvdtpVersion()
+ *
+ * Description      Gets the local version of AVDTP
+ *
+ * Returns          The local version of AVDTP.
+ *
+ *****************************************************************************/
+extern uint16_t A2DP_GetAvdtpVersion(void);
+
+/******************************************************************************
+ *
  * Function         A2DP_SetTraceLevel
  *
  * Description      Sets the trace level for A2D. If 0xff is passed, the
diff --git a/system/stack/include/avdt_api.h b/system/stack/include/avdt_api.h
index 24108bc..aaee2da 100644
--- a/system/stack/include/avdt_api.h
+++ b/system/stack/include/avdt_api.h
@@ -34,7 +34,7 @@
 #ifndef AVDT_VERSION
 #define AVDT_VERSION 0x0102
 #endif
-#define AVDT_VERSION_SYNC 0x0103
+#define AVDT_VERSION_1_3 0x0103
 
 /* Maximum size in bytes of the codec capabilities information element. */
 #define AVDT_CODEC_SIZE 20