Disable sniff for faulty remotes

Some remote supports sniff but when dut initiates sniff req,
remote wont respond and acl connection will be terminated
from soc with LMP responce time out

Tag: #compatibility
Bug: 163109241
Test: Manual
Change-Id: I77b5c0daf22c9f3adaf2a7b75c20bc8e27d8990c
Merged-In: I77b5c0daf22c9f3adaf2a7b75c20bc8e27d8990c
diff --git a/device/include/interop.h b/device/include/interop.h
index 02c1a5e..efbafa1 100644
--- a/device/include/interop.h
+++ b/device/include/interop.h
@@ -102,7 +102,12 @@
   INTEROP_DISABLE_NAME_REQUEST,
 
   // Respond AVRCP profile version only 1.4 for some device.
-  INTEROP_AVRCP_1_4_ONLY
+  INTEROP_AVRCP_1_4_ONLY,
+
+  // 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_feature_t;
 
 // Check if a given |addr| matches a known interoperability workaround as
diff --git a/device/src/interop.cc b/device/src/interop.cc
index 74543bf..a1e45d2 100644
--- a/device/src/interop.cc
+++ b/device/src/interop.cc
@@ -133,6 +133,7 @@
     CASE_RETURN_STR(INTEROP_HID_HOST_LIMIT_SNIFF_INTERVAL)
     CASE_RETURN_STR(INTEROP_DISABLE_NAME_REQUEST)
     CASE_RETURN_STR(INTEROP_AVRCP_1_4_ONLY)
+    CASE_RETURN_STR(INTEROP_DISABLE_SNIFF)
   }
 
   return "UNKNOWN";
diff --git a/stack/btm/btm_acl.cc b/stack/btm/btm_acl.cc
index 3c8a6a6..72239d9 100644
--- a/stack/btm/btm_acl.cc
+++ b/stack/btm/btm_acl.cc
@@ -746,7 +746,8 @@
                     *settings);
     }
     if ((*settings & HCI_ENABLE_SNIFF_MODE) &&
-        (!HCI_SNIFF_MODE_SUPPORTED(localFeatures))) {
+        ((!HCI_SNIFF_MODE_SUPPORTED(localFeatures)) ||
+         interop_match_addr(INTEROP_DISABLE_SNIFF, &remote_bda))) {
       *settings &= (~HCI_ENABLE_SNIFF_MODE);
       BTM_TRACE_API("BTM_SetLinkPolicy sniff not supported (settings: 0x%04x)",
                     *settings);
diff --git a/stack/btm/btm_pm.cc b/stack/btm/btm_pm.cc
index 793c854..60d5b06 100644
--- a/stack/btm/btm_pm.cc
+++ b/stack/btm/btm_pm.cc
@@ -42,6 +42,7 @@
 #include "btm_int.h"
 #include "btm_int_types.h"
 #include "btu.h"
+#include "device/include/interop.h"
 #include "hcidefs.h"
 #include "hcimsgs.h"
 #include "l2c_int.h"
@@ -177,7 +178,8 @@
     /* check if the requested mode is supported */
     ind = mode - BTM_PM_MD_HOLD; /* make it base 0 */
     p_features = BTM_ReadLocalFeatures();
-    if (!(p_features[btm_pm_mode_off[ind]] & btm_pm_mode_msk[ind])) {
+    if (!(p_features[btm_pm_mode_off[ind]] & btm_pm_mode_msk[ind]) ||
+            interop_match_addr(INTEROP_DISABLE_SNIFF, &remote_bda)) {
       LOG(ERROR) << __func__ << ": pm_id " << unsigned(pm_id) << " mode "
                  << unsigned(mode) << " is not supported for " << remote_bda;
       return BTM_MODE_UNSUPPORTED;