OSDN Git Service

JustWorks: Auto-accept only incoming temporary pairing.
authorMartin Brabham <optedoblivion@google.com>
Wed, 2 Oct 2019 01:06:15 +0000 (18:06 -0700)
committerandroid-build-merger <android-build-merger@google.com>
Wed, 2 Oct 2019 01:06:15 +0000 (18:06 -0700)
am: 10e15ee461

Change-Id: I392280bb44e2ab665baeab5ef5f1e6b9323fe463

btif/src/btif_dm.cc

index 7c62ad8..3aa56d2 100644 (file)
@@ -924,6 +924,7 @@ static void btif_dm_ssp_cfm_req_evt(tBTA_DM_SP_CFM_REQ* p_ssp_cfm_req) {
   bt_bdaddr_t bd_addr;
   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__);
@@ -956,6 +957,19 @@ 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 NOT needed if:
+     * 1. Incoming temporary pairing is detected
+     */
+    if (is_incoming && pairing_cb.bond_type == BOND_TYPE_TEMPORARY) {
+      BTIF_TRACE_EVENT(
+          "%s: Auto-accept JustWorks pairing for temporary incoming", __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) {