max_resps is always 0: unlimited

Bug: 159815595
Tag: #refactor
Test: compile & verify basic functions working
Change-Id: I734ece7fed7426795ea7ccfd0b3c7121ffe08655
diff --git a/system/main/shim/btm_api.cc b/system/main/shim/btm_api.cc
index 5a6559e..254004c 100644
--- a/system/main/shim/btm_api.cc
+++ b/system/main/shim/btm_api.cc
@@ -61,20 +61,6 @@
 extern void btm_sort_inq_result(void);
 extern void btm_process_inq_complete(uint8_t status, uint8_t result_type);
 
-static bool max_responses_reached() {
-  return (btm_cb.btm_inq_vars.inqparms.max_resps &&
-          btm_cb.btm_inq_vars.inq_cmpl_info.num_resp >=
-              btm_cb.btm_inq_vars.inqparms.max_resps);
-}
-
-static bool is_periodic_inquiry_active() {
-  return btm_cb.btm_inq_vars.inq_active & BTM_PERIODIC_INQUIRY_ACTIVE;
-}
-
-static bool has_le_device(tBT_DEVICE_TYPE device_type) {
-  return device_type & BT_DEVICE_TYPE_BLE;
-}
-
 static bool is_classic_device(tBT_DEVICE_TYPE device_type) {
   return device_type == BT_DEVICE_TYPE_BREDR;
 }
@@ -83,35 +69,11 @@
   return device_type & BT_DEVICE_TYPE_BREDR;
 }
 
-static bool is_dual_mode_device(tBT_DEVICE_TYPE device_type) {
-  return device_type == BT_DEVICE_TYPE_DUMO;
-}
-
-static bool is_observing_or_active_scanning() {
-  return btm_cb.btm_inq_vars.inqparms.mode & BTM_BLE_INQUIRY_MASK;
-}
-
-static void check_exceeded_responses(tBT_DEVICE_TYPE device_type,
-                                     bool scan_rsp) {
-  if (!is_periodic_inquiry_active() && max_responses_reached() &&
-      ((is_observing_or_active_scanning() && is_dual_mode_device(device_type) &&
-        scan_rsp) ||
-       (is_observing_or_active_scanning()))) {
-    LOG_INFO("UNIMPLEMENTED %s Device max responses found...cancelling inquiry",
-             __func__);
-  }
-}
-
 void btm_api_process_inquiry_result(const RawAddress& raw_address,
                                     uint8_t page_scan_rep_mode,
                                     DEV_CLASS device_class,
                                     uint16_t clock_offset) {
   tINQ_DB_ENT* p_i = btm_inq_db_find(raw_address);
-  if (max_responses_reached()) {
-    if (p_i == nullptr || !has_le_device(p_i->inq_info.results.device_type)) {
-      return;
-    }
-  }
 
   if (p_i == nullptr) {
     p_i = btm_inq_db_new(raw_address);
@@ -143,7 +105,6 @@
     p_i->inq_info.results.device_type |= BT_DEVICE_TYPE_BREDR;
   }
 
-  check_exceeded_responses(p_i->inq_info.results.device_type, p_i->scan_rsp);
   if (btm_cb.btm_inq_vars.p_inq_results_cb == nullptr) {
     return;
   }
@@ -157,11 +118,6 @@
                                               uint16_t clock_offset,
                                               int8_t rssi) {
   tINQ_DB_ENT* p_i = btm_inq_db_find(raw_address);
-  if (max_responses_reached()) {
-    if (p_i == nullptr || !has_le_device(p_i->inq_info.results.device_type)) {
-      return;
-    }
-  }
 
   bool update = false;
   if (btm_inq_find_bdaddr(raw_address)) {
@@ -206,7 +162,6 @@
     }
   }
 
-  check_exceeded_responses(p_i->inq_info.results.device_type, p_i->scan_rsp);
   if (btm_cb.btm_inq_vars.p_inq_results_cb == nullptr) {
     return;
   }
@@ -222,11 +177,6 @@
                                              const uint8_t* eir_data,
                                              size_t eir_len) {
   tINQ_DB_ENT* p_i = btm_inq_db_find(raw_address);
-  if (max_responses_reached()) {
-    if (p_i == nullptr || !has_le_device(p_i->inq_info.results.device_type)) {
-      return;
-    }
-  }
 
   bool update = false;
   if (btm_inq_find_bdaddr(raw_address) && p_i != nullptr) {
@@ -266,7 +216,6 @@
     }
   }
 
-  check_exceeded_responses(p_i->inq_info.results.device_type, p_i->scan_rsp);
   if (btm_cb.btm_inq_vars.p_inq_results_cb == nullptr) {
     return;
   }
@@ -290,8 +239,6 @@
   inqparms.mode = BTM_GENERAL_INQUIRY | BTM_BLE_GENERAL_INQUIRY;
   inqparms.duration = BTIF_DM_DEFAULT_INQ_MAX_DURATION;
 
-  inqparms.max_resps = BTIF_DM_DEFAULT_INQ_MAX_RESULTS;
-
   std::lock_guard<std::mutex> lock(btm_cb_mutex_);
 
   btm_cb.btm_inq_vars.inq_cmpl_info.num_resp = 0;
@@ -317,7 +264,7 @@
   }
 
   if (!Stack::GetInstance()->GetBtm()->StartInquiry(
-          classic_mode, inqparms.duration, inqparms.max_resps,
+          classic_mode, inqparms.duration, 0,
           [](uint16_t status, uint8_t inquiry_mode) {
             LOG_DEBUG("%s Inquiry is complete status:%hd inquiry_mode:%hhd",
                       __func__, status, inquiry_mode);
diff --git a/system/main/shim/btm_api.h b/system/main/shim/btm_api.h
index f6d432b..85fca8b 100644
--- a/system/main/shim/btm_api.h
+++ b/system/main/shim/btm_api.h
@@ -34,8 +34,6 @@
  *                      mode - GENERAL or LIMITED inquiry
  *                      duration - length in 1.28 sec intervals (If '0', the
  *                                 inquiry is CANCELLED)
- *                      max_resps - maximum amount of devices to search for
- *                                  before ending the inquiry
  *                      filter_cond_type - BTM_CLR_INQUIRY_FILTER,
  *                                         BTM_FILTER_COND_DEVICE_CLASS, or
  *                                         BTM_FILTER_COND_BD_ADDR
diff --git a/system/stack/btm/btm_ble_gap.cc b/system/stack/btm/btm_ble_gap.cc
index 5ecd387..bf29be8 100644
--- a/system/stack/btm/btm_ble_gap.cc
+++ b/system/stack/btm/btm_ble_gap.cc
@@ -1915,29 +1915,6 @@
   }
 
   if (!update) result &= ~BTM_BLE_INQ_RESULT;
-  /* If the number of responses found and limited, issue a cancel inquiry */
-  if (p_inq->inqparms.max_resps &&
-      p_inq->inq_cmpl_info.num_resp == p_inq->inqparms.max_resps) {
-    /* new device */
-    if (p_i == NULL ||
-        /* assume a DUMO device, BR/EDR inquiry is always active */
-        (p_i &&
-         (p_i->inq_info.results.device_type & BT_DEVICE_TYPE_BLE) ==
-             BT_DEVICE_TYPE_BLE &&
-         p_i->scan_rsp)) {
-      BTM_TRACE_WARNING(
-          "INQ RES: Extra Response Received...cancelling inquiry..");
-
-      /* if is non-periodic inquiry active, cancel now */
-      if ((p_inq->inq_active & BTM_BR_INQ_ACTIVE_MASK) != 0 &&
-          (p_inq->inq_active & BTM_PERIODIC_INQUIRY_ACTIVE) == 0)
-        btsnd_hcic_inq_cancel();
-
-      btm_ble_stop_inquiry();
-
-      btm_acl_update_inquiry_status(BTM_INQUIRY_COMPLETE);
-    }
-  }
 
   tBTM_INQ_RESULTS_CB* p_inq_results_cb = p_inq->p_inq_results_cb;
   if (p_inq_results_cb && (result & BTM_BLE_INQ_RESULT)) {
diff --git a/system/stack/btm/btm_inq.cc b/system/stack/btm/btm_inq.cc
index 4cb38aa..848a2b6 100644
--- a/system/stack/btm/btm_inq.cc
+++ b/system/stack/btm/btm_inq.cc
@@ -56,7 +56,6 @@
 #define BTM_INQ_DEBUG FALSE
 #endif
 
-#define BTIF_DM_DEFAULT_INQ_MAX_RESULTS 0
 #define BTIF_DM_DEFAULT_INQ_MAX_DURATION 10
 
 /******************************************************************************/
@@ -568,8 +567,6 @@
  *                             seperately
  *                      duration - length in 1.28 sec intervals (If '0', the
  *                                 inquiry is CANCELLED)
- *                      max_resps - maximum amount of devices to search for
- *                                  before ending the inquiry
  *                      filter_cond_type - BTM_CLR_INQUIRY_FILTER,
  *                                         BTM_FILTER_COND_DEVICE_CLASS, or
  *                                         BTM_FILTER_COND_BD_ADDR
@@ -623,8 +620,6 @@
   p_inq->inqparms.mode = BTM_GENERAL_INQUIRY | BTM_BLE_GENERAL_INQUIRY;
   p_inq->inqparms.duration = BTIF_DM_DEFAULT_INQ_MAX_DURATION;
 
-  p_inq->inqparms.max_resps = BTIF_DM_DEFAULT_INQ_MAX_RESULTS;
-
   /* Initialize the inquiry variables */
   p_inq->state = BTM_INQ_ACTIVE_STATE;
   p_inq->p_inq_cmpl_cb = p_cmpl_cb;
@@ -1144,8 +1139,6 @@
  *                      mode - GENERAL or LIMITED inquiry
  *                      duration - length in 1.28 sec intervals
  *                                 (If '0', the inquiry is CANCELLED)
- *                      max_resps - maximum amount of devices to search for
- *                                  before ending the inquiry
  *                      filter_cond_type - BTM_CLR_INQUIRY_FILTER,
  *                                         BTM_FILTER_COND_DEVICE_CLASS, or
  *                                         BTM_FILTER_COND_BD_ADDR
@@ -1175,18 +1168,12 @@
     return;
   }
 
-  /* Make sure the number of responses doesn't overflow the database
-   * configuration */
-  p_inqparms->max_resps = (uint8_t)((p_inqparms->max_resps <= BTM_INQ_DB_SIZE)
-                                        ? p_inqparms->max_resps
-                                        : BTM_INQ_DB_SIZE);
-
   lap = (p_inq->inq_active & BTM_LIMITED_INQUIRY_ACTIVE) ? &limited_inq_lap
                                                          : &general_inq_lap;
 
   if (p_inq->inq_active & BTM_PERIODIC_INQUIRY_ACTIVE) {
     btsnd_hcic_per_inq_mode(p_inq->per_max_delay, p_inq->per_min_delay, *lap,
-                            p_inqparms->duration, p_inqparms->max_resps);
+                            p_inqparms->duration, 0);
   } else {
     btm_clr_inq_result_flt();
 
@@ -1285,22 +1272,6 @@
     }
 
     p_i = btm_inq_db_find(bda);
-    /* Only process the num_resp is smaller than max_resps.
-       If results are queued to BTU task while canceling inquiry,
-       or when more than one result is in this response, > max_resp
-       responses could be processed which can confuse some apps
-    */
-    if (p_inq->inqparms.max_resps &&
-        p_inq->inq_cmpl_info.num_resp >= p_inq->inqparms.max_resps
-        /* new device response */
-        &&
-        (p_i == NULL ||
-         /* exisiting device with BR/EDR info */
-         (p_i &&
-          (p_i->inq_info.results.device_type & BT_DEVICE_TYPE_BREDR) != 0))) {
-      /* BTM_TRACE_WARNING("INQ RES: Extra Response Received...ignoring"); */
-      return;
-    }
 
     /* Check if this address has already been processed for this inquiry */
     if (btm_inq_find_bdaddr(bda)) {
@@ -1380,23 +1351,6 @@
         p_cur->device_type |= BT_DEVICE_TYPE_BREDR;
       p_i->inq_count = p_inq->inq_counter; /* Mark entry for current inquiry */
 
-      /* If the number of responses found and not unlimited, issue a cancel
-       * inquiry */
-      if (!(p_inq->inq_active & BTM_PERIODIC_INQUIRY_ACTIVE) &&
-          p_inq->inqparms.max_resps &&
-          p_inq->inq_cmpl_info.num_resp == p_inq->inqparms.max_resps &&
-          /* BLE scanning is active and received adv */
-          ((((p_inq->inqparms.mode & BTM_BLE_INQUIRY_MASK) != 0) &&
-            p_cur->device_type == BT_DEVICE_TYPE_DUMO && p_i->scan_rsp) ||
-           (p_inq->inqparms.mode & BTM_BLE_INQUIRY_MASK) == 0)) {
-        /*                BTM_TRACE_DEBUG("BTMINQ: Found devices, cancelling
-         * inquiry..."); */
-        btsnd_hcic_inq_cancel();
-
-        if ((p_inq->inqparms.mode & BTM_BLE_INQUIRY_MASK) != 0)
-          btm_ble_stop_inquiry();
-        btm_acl_update_inquiry_status(BTM_INQUIRY_COMPLETE);
-      }
       /* Initialize flag to false. This flag is set/used by application */
       p_i->inq_info.appl_knows_rem_name = false;
     }
diff --git a/system/stack/include/btm_api.h b/system/stack/include/btm_api.h
index 01989a9..608f15e 100644
--- a/system/stack/include/btm_api.h
+++ b/system/stack/include/btm_api.h
@@ -278,8 +278,6 @@
  *                      mode - GENERAL or LIMITED inquiry
  *                      duration - length in 1.28 sec intervals (If '0', the
  *                                 inquiry is CANCELLED)
- *                      max_resps - maximum amount of devices to search for
- *                                  before ending the inquiry
  *                      filter_cond_type - BTM_CLR_INQUIRY_FILTER,
  *                                         BTM_FILTER_COND_DEVICE_CLASS, or
  *                                         BTM_FILTER_COND_BD_ADDR
diff --git a/system/stack/include/btm_api_types.h b/system/stack/include/btm_api_types.h
index 64b464f..0263c75 100644
--- a/system/stack/include/btm_api_types.h
+++ b/system/stack/include/btm_api_types.h
@@ -416,7 +416,6 @@
 {
   uint8_t mode;      /* general or limited */
   uint8_t duration;  /* duration of the inquiry (1.28 sec increments) */
-  uint8_t max_resps; /* maximum number of responses to return */
   tBTM_INQ_FILT_COND filter_cond; /* filter value based on filter cond type */
 } tBTM_INQ_PARMS;