OSDN Git Service

DO NOT MERGE ANYWHERE Add Wear-specific feature to override LE IO capability
authorJacky Cheung <jackyc@google.com>
Wed, 19 Oct 2016 21:59:06 +0000 (14:59 -0700)
committerJacky Cheung <jackyc@google.com>
Wed, 19 Oct 2016 22:39:53 +0000 (15:39 -0700)
Force the first bond to use Just Works pairing when
WEAR_LE_IO_CAP_OVERRIDE is set to TRUE.

Bug: 32234733
Change-Id: I1732be86dd888586c603112fb6c3010974b54a13

btif/co/bta_dm_co.c
btif/include/btif_storage.h
btif/src/btif_storage.c
include/bt_target.h

index 343010f..55b2f86 100644 (file)
@@ -24,6 +24,9 @@
 #include "bta_dm_ci.h"
 #include "bt_utils.h"
 #include "btif_dm.h"
+#if (defined WEAR_LE_IO_CAP_OVERRIDE && WEAR_LE_IO_CAP_OVERRIDE == TRUE)
+#include "btif_storage.h"
+#endif
 #if (defined BLE_INCLUDED && BLE_INCLUDED == TRUE)
 #include "bte_appl.h"
 
@@ -402,7 +405,24 @@ void bta_dm_co_ble_io_req(BD_ADDR bd_addr,  tBTA_IO_CAP *p_io_cap,
                           tBTA_LE_KEY_TYPE  *p_resp_key )
 {
     UNUSED(bd_addr);
-    /* Retrieve the properties from file system if possible */
+
+
+#if (defined WEAR_LE_IO_CAP_OVERRIDE && WEAR_LE_IO_CAP_OVERRIDE == TRUE)
+    /*
+     * Note: This is a Wear-specific feature for iOS pairing.
+     *
+     * Set WearLeIoCap config to force local IO capability to be BTM_IO_CAP_NONE
+     * (No input, no output) for the first bond creation, that indirectly
+     * triggers Just Works pairing.
+     */
+    if (btif_storage_get_num_bonded_devices() == 0)
+        bte_appl_cfg.ble_io_cap = BTM_IO_CAP_NONE;
+#endif
+
+    /* For certification testing purpose, LE IO capability can also be specified with
+     * "PTS_SmpOptions" in the BT stack configuration file (i.e. bt_stack.conf).
+     * Note that if "PTS_SmpOptions" is set, it could override IO capability set above.
+     */
     tBTE_APPL_CFG nv_config;
     if(btif_dm_get_smp_config(&nv_config))
         bte_appl_cfg = nv_config;
index bc1060c..5309ce0 100644 (file)
@@ -274,6 +274,16 @@ bt_status_t btif_storage_remove_hid_info(bt_bdaddr_t *remote_bd_addr);
 *******************************************************************************/
 BOOLEAN btif_storage_is_restricted_device(const bt_bdaddr_t *remote_bd_addr);
 
+/*******************************************************************************
+**
+** Function         btif_storage_get_num_bonded_devices
+**
+** Description      BTIF storage API - Gets the number of bonded devices
+**
+** Returns          the number of bonded devices
+**
+*******************************************************************************/
+int btif_storage_get_num_bonded_devices(void);
 #if (BLE_INCLUDED == TRUE)
 bt_status_t btif_storage_add_ble_bonding_key( bt_bdaddr_t *remote_bd_addr,
                                               char *key,
index 82d377d..83dcc8c 100644 (file)
@@ -1422,6 +1422,21 @@ bt_status_t btif_storage_remove_hid_info(bt_bdaddr_t *remote_bd_addr)
 
 /*******************************************************************************
 **
+** Function         btif_storage_get_num_bonded_devices
+**
+** Description      BTIF storage API - Gets the number of bonded devices
+**
+** Returns          the number of bonded devices
+**
+*******************************************************************************/
+int btif_storage_get_num_bonded_devices(void) {
+    btif_bonded_devices_t bonded_devices;
+    btif_in_fetch_bonded_devices(&bonded_devices, 0);
+    return bonded_devices.num_devices;
+}
+
+/*******************************************************************************
+**
 ** Function         btif_storage_read_hl_apps_cb
 **
 ** Description      BTIF storage API - Read HL application control block from NVRAM
index 45e2e78..184a6cd 100644 (file)
@@ -1555,4 +1555,15 @@ The maximum number of payload octets that the local device can receive in a sing
 
 #include "bt_trace.h"
 
+/******************************************************************************
+**
+** Wear
+**
+******************************************************************************/
+
+/* Enable/disable LE IO capability overriding to no-input-no-output on first bond */
+#ifndef WEAR_LE_IO_CAP_OVERRIDE
+#define WEAR_LE_IO_CAP_OVERRIDE FALSE
+#endif
+
 #endif /* BT_TARGET_H */