OSDN Git Service

Disable sniff for faulty remotes
authorVenkata Jagadeesh Garaga <vgaraga@codeaurora.org>
Thu, 23 May 2019 12:43:53 +0000 (18:13 +0530)
committerTed Wang <tedwang@google.com>
Thu, 12 Nov 2020 09:00:24 +0000 (17:00 +0800)
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

device/include/interop.h
device/src/interop.cc
stack/acl/btm_acl.cc
stack/acl/btm_pm.cc

index 02c1a5e..efbafa1 100644 (file)
@@ -102,7 +102,12 @@ typedef enum {
   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
index 11c3593..773e413 100644 (file)
@@ -132,6 +132,7 @@ static const char* interop_feature_string_(const interop_feature_t feature) {
     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";
index f7df321..985264e 100644 (file)
@@ -624,6 +624,10 @@ static void check_link_policy(uint16_t* settings) {
 static void btm_set_link_policy(tACL_CONN* conn, uint16_t policy) {
   conn->link_policy = policy;
   check_link_policy(&conn->link_policy);
+  if ((conn->link_policy & HCI_ENABLE_CENTRAL_PERIPHERAL_SWITCH) &&
+      interop_match_addr(INTEROP_DISABLE_SNIFF, &(conn->remote_addr))) {
+    conn->link_policy &= (~HCI_ENABLE_SNIFF_MODE);
+  }
   btsnd_hcic_write_policy_set(conn->hci_handle, conn->link_policy);
 }
 
index 5eef579..8ac5fd5 100644 (file)
@@ -39,6 +39,7 @@
 #include "btm_int.h"
 #include "btm_int_types.h"
 #include "device/include/controller.h"
+#include "device/include/interop.h"
 #include "hcidefs.h"
 #include "hcimsgs.h"
 #include "osi/include/log.h"
@@ -160,7 +161,8 @@ tBTM_STATUS BTM_SetPowerMode(uint8_t pm_id, const RawAddress& remote_bda,
     const controller_t* controller = controller_get_interface();
     if ((mode == BTM_PM_MD_HOLD && !controller->supports_hold_mode()) ||
         (mode == BTM_PM_MD_SNIFF && !controller->supports_sniff_mode()) ||
-        (mode == BTM_PM_MD_PARK && !controller->supports_park_mode())) {
+        (mode == BTM_PM_MD_PARK && !controller->supports_park_mode()) ||
+        interop_match_addr(INTEROP_DISABLE_SNIFF, &remote_bda)) {
       LOG_ERROR("pm_id %u mode %u is not supported for %s", pm_id, mode,
                 remote_bda.ToString().c_str());
       return BTM_MODE_UNSUPPORTED;