Merge cherrypicks of [13320072, 13319971, 13320351, 13320073, 13320352, 13320131, 13320074, 13320075, 13321410, 13320132, 13319972, 13320076, 13320077, 13320353, 13320354] into rvc-qpr2-release

Change-Id: I66371f95d81b69b7e54ac9a45bcb859f3662ec53
diff --git a/bta/ag/bta_ag_sdp.cc b/bta/ag/bta_ag_sdp.cc
index 88b3bdb..dd9ec3c 100644
--- a/bta/ag/bta_ag_sdp.cc
+++ b/bta/ag/bta_ag_sdp.cc
@@ -34,6 +34,7 @@
 #include "bta_sys.h"
 #include "btif_config.h"
 #include "btm_api.h"
+#include "osi/include/log.h"
 #include "osi/include/osi.h"
 #include "sdp_api.h"
 #include "stack/include/btu.h"
@@ -477,6 +478,12 @@
     }
   }
 
+  if (p_scb->p_disc_db != nullptr) {
+    android_errorWriteLog(0x534e4554, "174052148");
+    APPL_TRACE_ERROR("Discovery already in progress... returning.");
+    return;
+  }
+
   /* allocate buffer for sdp database */
   p_scb->p_disc_db = (tSDP_DISCOVERY_DB*)osi_malloc(BTA_AG_DISC_BUF_SIZE);
   /* set up service discovery database; attr happens to be attr_list len */