• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/bt


Commit MetaInfo

Revision5059267dc12faca90fa740bdb6394300adfd21f0 (tree)
Time2019-06-05 01:39:19
AuthorTreeHugger Robot <treehugger-gerrit@goog...>
CommiterAndroid (Google) Code Review

Log Message

Merge "DO NOT MERGE Separate SDP procedure from bonding state (1/2)" into nyc-dev

Change Summary

Incremental Difference

--- a/btif/src/btif_dm.c
+++ b/btif/src/btif_dm.c
@@ -191,6 +191,7 @@ typedef struct
191191 #define BTA_SERVICE_ID_TO_SERVICE_MASK(id) (1 << (id))
192192
193193 #define UUID_HUMAN_INTERFACE_DEVICE "00001124-0000-1000-8000-00805f9b34fb"
194+#define UUID_EMPTY "00000000-0000-0000-0000-000000000000"
194195
195196 #define MAX_BTIF_BOND_EVENT_ENTRIES 15
196197
@@ -269,6 +270,11 @@ static bool is_empty_128bit(uint8_t *data)
269270 return !memcmp(zero, data, sizeof(zero));
270271 }
271272
273+static bool is_bonding_or_sdp() {
274+ return pairing_cb.state == BT_BOND_STATE_BONDING ||
275+ (pairing_cb.state == BT_BOND_STATE_BONDED && pairing_cb.sdp_attempts);
276+}
277+
272278 static void btif_dm_data_copy(uint16_t event, char *dst, char *src)
273279 {
274280 tBTA_DM_SEC *dst_dm_sec = (tBTA_DM_SEC*)dst;
@@ -550,15 +556,14 @@ static void bond_state_changed(bt_status_t status, bt_bdaddr_t *bd_addr, bt_bond
550556
551557 HAL_CBACK(bt_hal_cbacks, bond_state_changed_cb, status, bd_addr, state);
552558
553- if (state == BT_BOND_STATE_BONDING)
559+ if (state == BT_BOND_STATE_BONDING ||
560+ (state == BT_BOND_STATE_BONDED && pairing_cb.sdp_attempts > 0))
554561 {
562+ // Save state for the device is bonding or SDP.
555563 pairing_cb.state = state;
556564 bdcpy(pairing_cb.bd_addr, bd_addr->address);
557565 } else {
558- if (!pairing_cb.sdp_attempts)
559- memset(&pairing_cb, 0, sizeof(pairing_cb));
560- else
561- BTIF_TRACE_DEBUG("%s: BR-EDR service discovery active", __func__);
566+ memset(&pairing_cb, 0, sizeof(pairing_cb));
562567 }
563568 }
564569
@@ -1178,6 +1183,14 @@ static void btif_dm_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
11781183
11791184 // Ensure inquiry is stopped before attempting service discovery
11801185 btif_dm_cancel_discovery();
1186+ if (is_crosskey) {
1187+ // If bonding occurred due to cross-key pairing, send bonding callback
1188+ // for static address now
1189+ LOG_INFO(LOG_TAG,
1190+ "%s: send bonding state update for static address", __func__);
1191+ bond_state_changed(BT_STATUS_SUCCESS, &bd_addr, BT_BOND_STATE_BONDING);
1192+ }
1193+ bond_state_changed(BT_STATUS_SUCCESS, &bd_addr, BT_BOND_STATE_BONDED);
11811194
11821195 /* Trigger SDP on the device */
11831196 pairing_cb.sdp_attempts = 1;
@@ -1471,7 +1484,7 @@ static void btif_dm_search_services_evt(UINT16 event, char *p_param)
14711484 BTIF_TRACE_DEBUG("%s:(result=0x%x, services 0x%x)", __FUNCTION__,
14721485 p_data->disc_res.result, p_data->disc_res.services);
14731486 if ((p_data->disc_res.result != BTA_SUCCESS) &&
1474- (pairing_cb.state == BT_BOND_STATE_BONDING ) &&
1487+ (pairing_cb.state == BT_BOND_STATE_BONDED) &&
14751488 (pairing_cb.sdp_attempts < BTIF_DM_MAX_SDP_ATTEMPTS_AFTER_PAIRING))
14761489 {
14771490 BTIF_TRACE_WARNING("%s:SDP failed after bonding re-attempting", __FUNCTION__);
@@ -1496,21 +1509,37 @@ static void btif_dm_search_services_evt(UINT16 event, char *p_param)
14961509 /* onUuidChanged requires getBondedDevices to be populated.
14971510 ** bond_state_changed needs to be sent prior to remote_device_property
14981511 */
1499- if ((pairing_cb.state == BT_BOND_STATE_BONDING) &&
1512+ if ((pairing_cb.state == BT_BOND_STATE_BONDED && pairing_cb.sdp_attempts) &&
15001513 ((bdcmp(p_data->disc_res.bd_addr, pairing_cb.bd_addr) == 0) ||
1501- (bdcmp(p_data->disc_res.bd_addr, pairing_cb.static_bdaddr.address) == 0)) &&
1502- pairing_cb.sdp_attempts > 0)
1514+ (bdcmp(p_data->disc_res.bd_addr, pairing_cb.static_bdaddr.address) == 0)))
15031515 {
1504- BTIF_TRACE_DEBUG("%s Remote Service SDP done. Call bond_state_changed_cb BONDED",
1505- __FUNCTION__);
1516+ LOG_INFO(LOG_TAG, "%s Remote Service SDP done.", __FUNCTION__);
15061517 pairing_cb.sdp_attempts = 0;
15071518
1508- // If bonding occured due to cross-key pairing, send bonding callback
1509- // for static address now
1510- if (bdcmp(p_data->disc_res.bd_addr, pairing_cb.static_bdaddr.address) == 0)
1511- bond_state_changed(BT_STATUS_SUCCESS, &bd_addr, BT_BOND_STATE_BONDING);
1519+ // Both SDP and bonding are done, clear pairing control block
1520+ memset(&pairing_cb, 0, sizeof(pairing_cb));
1521+
1522+ // Send one empty UUID to Java to unblock pairing intent when SDP failed
1523+ // or no UUID is discovered
1524+ if (p_data->disc_res.result == BTA_SUCCESS ||
1525+ p_data->disc_res.num_uuids == 0) {
1526+ LOG_INFO(LOG_TAG, "%s: SDP failed, send empty UUID to unblock bonding",
1527+ __func__);
1528+ bt_property_t prop;
1529+ bt_uuid_t uuid = {};
1530+ char uuid_str[128] = UUID_EMPTY;
15121531
1513- bond_state_changed(BT_STATUS_SUCCESS, &bd_addr, BT_BOND_STATE_BONDED);
1532+ string_to_uuid(uuid_str, &uuid);
1533+
1534+ prop.type = BT_PROPERTY_UUIDS;
1535+ prop.val = uuid.uu;
1536+ prop.len = MAX_UUID_SIZE;
1537+
1538+ /* Send the event to the BTIF */
1539+ HAL_CBACK(bt_hal_cbacks, remote_device_properties_cb,
1540+ BT_STATUS_SUCCESS, &bd_addr, 1, &prop);
1541+ break;
1542+ }
15141543 }
15151544
15161545 if (p_data->disc_res.num_uuids != 0)
@@ -1730,7 +1759,7 @@ static void btif_dm_upstreams_evt(UINT16 event, char* p_param)
17301759 break;
17311760
17321761 case BTA_DM_BOND_CANCEL_CMPL_EVT:
1733- if (pairing_cb.state == BT_BOND_STATE_BONDING)
1762+ if (is_bonding_or_sdp())
17341763 {
17351764 bdcpy(bd_addr.address, pairing_cb.bd_addr);
17361765 btm_set_bond_type_dev(pairing_cb.bd_addr, BOND_TYPE_UNKNOWN);
@@ -2380,7 +2409,7 @@ bt_status_t btif_dm_cancel_bond(const bt_bdaddr_t *bd_addr)
23802409 ** 1. Restore scan modes
23812410 ** 2. special handling for HID devices
23822411 */
2383- if (pairing_cb.state == BT_BOND_STATE_BONDING)
2412+ if (is_bonding_or_sdp())
23842413 {
23852414
23862415 #if (defined(BLE_INCLUDED) && (BLE_INCLUDED == TRUE))
@@ -2442,7 +2471,7 @@ bt_status_t btif_dm_cancel_bond(const bt_bdaddr_t *bd_addr)
24422471
24432472 void btif_dm_hh_open_failed(bt_bdaddr_t *bdaddr)
24442473 {
2445- if (pairing_cb.state == BT_BOND_STATE_BONDING &&
2474+ if (is_bonding_or_sdp() &&
24462475 bdcmp(bdaddr->address, pairing_cb.bd_addr) == 0)
24472476 {
24482477 bond_state_changed(BT_STATUS_FAIL, bdaddr, BT_BOND_STATE_NONE);
@@ -3073,6 +3102,11 @@ static void btif_dm_ble_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
30733102 break;
30743103 }
30753104 }
3105+ if (state == BT_BOND_STATE_BONDED &&
3106+ (bdcmp(bd_addr.address, pairing_cb.static_bdaddr.address) != 0)) {
3107+ // Report RPA bonding state to Java in crosskey paring
3108+ bond_state_changed(status, &bd_addr, BT_BOND_STATE_BONDING);
3109+ }
30763110 bond_state_changed(status, &bd_addr, state);
30773111 }
30783112
@@ -3386,7 +3420,7 @@ bt_status_t btif_le_test_mode(uint16_t opcode, uint8_t *buf, uint8_t len)
33863420 void btif_dm_on_disable()
33873421 {
33883422 /* cancel any pending pairing requests */
3389- if (pairing_cb.state == BT_BOND_STATE_BONDING)
3423+ if (is_bonding_or_sdp())
33903424 {
33913425 bt_bdaddr_t bd_addr;
33923426