OSDN Git Service

Revert "DO NOT MERGE: btif: require pairing dialog for JustWorks SSP"
authorMartin Brabham <optedoblivion@google.com>
Fri, 14 Jun 2019 16:27:42 +0000 (16:27 +0000)
committerMartin Brabham <optedoblivion@google.com>
Wed, 19 Jun 2019 01:30:32 +0000 (01:30 +0000)
This reverts commit 9437cbc24014799738c85da8f416a647f8cbf3e2.

Reason for revert: Waiting for QT first SMR due to b/134461862
Bug: 134461862
Change-Id: I3fea0f2d10658d6e154a946eaaa9fbdeb4b49159

btif/src/btif_dm.cc

index 40d3ec9..1f5cb82 100644 (file)
@@ -926,6 +926,7 @@ static void btif_dm_pin_req_evt(tBTA_DM_PIN_REQ* p_pin_req) {
 static void btif_dm_ssp_cfm_req_evt(tBTA_DM_SP_CFM_REQ* p_ssp_cfm_req) {
   bt_bdname_t bd_name;
   uint32_t cod;
+  bool is_incoming = !(pairing_cb.state == BT_BOND_STATE_BONDING);
   int dev_type;
 
   BTIF_TRACE_DEBUG("%s", __func__);
@@ -970,6 +971,28 @@ static void btif_dm_ssp_cfm_req_evt(tBTA_DM_SP_CFM_REQ* p_ssp_cfm_req) {
 
   pairing_cb.is_ssp = true;
 
+  /* If JustWorks auto-accept */
+  if (p_ssp_cfm_req->just_works) {
+    /* Pairing consent for JustWorks needed if:
+     * 1. Incoming (non-temporary) pairing is detected AND
+     * 2. local IO capabilities are DisplayYesNo AND
+     * 3. remote IO capabiltiies are DisplayOnly or NoInputNoOutput;
+     */
+    if (is_incoming && pairing_cb.bond_type != BOND_TYPE_TEMPORARY &&
+        ((p_ssp_cfm_req->loc_io_caps == HCI_IO_CAP_DISPLAY_YESNO) &&
+         (p_ssp_cfm_req->rmt_io_caps == HCI_IO_CAP_DISPLAY_ONLY ||
+          p_ssp_cfm_req->rmt_io_caps == HCI_IO_CAP_NO_IO))) {
+      BTIF_TRACE_EVENT(
+          "%s: User consent needed for incoming pairing request. loc_io_caps: "
+          "%d, rmt_io_caps: %d",
+          __func__, p_ssp_cfm_req->loc_io_caps, p_ssp_cfm_req->rmt_io_caps);
+    } else {
+      BTIF_TRACE_EVENT("%s: Auto-accept JustWorks pairing", __func__);
+      btif_dm_ssp_reply(&bd_addr, BT_SSP_VARIANT_CONSENT, true, 0);
+      return;
+    }
+  }
+
   cod = devclass2uint(p_ssp_cfm_req->dev_class);
 
   if (cod == 0) {