system/bt
リビジョン | 2acb8e2b1ce511bcf73ba131822bef592e9d5981 (tree) |
---|---|
日時 | 2019-07-16 04:43:34 |
作者 | Arjun Garg <arjgarg@goog...> |
コミッター | Arjun Garg |
Revert "DO NOT MERGE Separate SDP procedure from bonding state (1/2)"
This reverts commit 669c21e17874a11394668b2a927b04d03850d237.
@@ -191,7 +191,6 @@ typedef struct | ||
191 | 191 | #define BTA_SERVICE_ID_TO_SERVICE_MASK(id) (1 << (id)) |
192 | 192 | |
193 | 193 | #define UUID_HUMAN_INTERFACE_DEVICE "00001124-0000-1000-8000-00805f9b34fb" |
194 | -#define UUID_EMPTY "00000000-0000-0000-0000-000000000000" | |
195 | 194 | |
196 | 195 | #define MAX_BTIF_BOND_EVENT_ENTRIES 15 |
197 | 196 |
@@ -271,11 +270,6 @@ static bool is_empty_128bit(uint8_t *data) | ||
271 | 270 | return !memcmp(zero, data, sizeof(zero)); |
272 | 271 | } |
273 | 272 | |
274 | -static bool is_bonding_or_sdp() { | |
275 | - return pairing_cb.state == BT_BOND_STATE_BONDING || | |
276 | - (pairing_cb.state == BT_BOND_STATE_BONDED && pairing_cb.sdp_attempts); | |
277 | -} | |
278 | - | |
279 | 273 | static void btif_dm_data_copy(uint16_t event, char *dst, char *src) |
280 | 274 | { |
281 | 275 | tBTA_DM_SEC *dst_dm_sec = (tBTA_DM_SEC*)dst; |
@@ -557,14 +551,15 @@ static void bond_state_changed(bt_status_t status, bt_bdaddr_t *bd_addr, bt_bond | ||
557 | 551 | |
558 | 552 | HAL_CBACK(bt_hal_cbacks, bond_state_changed_cb, status, bd_addr, state); |
559 | 553 | |
560 | - if (state == BT_BOND_STATE_BONDING || | |
561 | - (state == BT_BOND_STATE_BONDED && pairing_cb.sdp_attempts > 0)) | |
554 | + if (state == BT_BOND_STATE_BONDING) | |
562 | 555 | { |
563 | - // Save state for the device is bonding or SDP. | |
564 | 556 | pairing_cb.state = state; |
565 | 557 | bdcpy(pairing_cb.bd_addr, bd_addr->address); |
566 | 558 | } else { |
567 | - memset(&pairing_cb, 0, sizeof(pairing_cb)); | |
559 | + if (!pairing_cb.sdp_attempts) | |
560 | + memset(&pairing_cb, 0, sizeof(pairing_cb)); | |
561 | + else | |
562 | + BTIF_TRACE_DEBUG("%s: BR-EDR service discovery active", __func__); | |
568 | 563 | } |
569 | 564 | } |
570 | 565 |
@@ -1217,14 +1212,6 @@ static void btif_dm_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl) | ||
1217 | 1212 | |
1218 | 1213 | // Ensure inquiry is stopped before attempting service discovery |
1219 | 1214 | btif_dm_cancel_discovery(); |
1220 | - if (is_crosskey) { | |
1221 | - // If bonding occurred due to cross-key pairing, send bonding callback | |
1222 | - // for static address now | |
1223 | - LOG_INFO(LOG_TAG, | |
1224 | - "%s: send bonding state update for static address", __func__); | |
1225 | - bond_state_changed(BT_STATUS_SUCCESS, &bd_addr, BT_BOND_STATE_BONDING); | |
1226 | - } | |
1227 | - bond_state_changed(BT_STATUS_SUCCESS, &bd_addr, BT_BOND_STATE_BONDED); | |
1228 | 1215 | |
1229 | 1216 | /* Trigger SDP on the device */ |
1230 | 1217 | pairing_cb.sdp_attempts = 1; |
@@ -1518,7 +1505,7 @@ static void btif_dm_search_services_evt(UINT16 event, char *p_param) | ||
1518 | 1505 | BTIF_TRACE_DEBUG("%s:(result=0x%x, services 0x%x)", __FUNCTION__, |
1519 | 1506 | p_data->disc_res.result, p_data->disc_res.services); |
1520 | 1507 | if ((p_data->disc_res.result != BTA_SUCCESS) && |
1521 | - (pairing_cb.state == BT_BOND_STATE_BONDED) && | |
1508 | + (pairing_cb.state == BT_BOND_STATE_BONDING ) && | |
1522 | 1509 | (pairing_cb.sdp_attempts < BTIF_DM_MAX_SDP_ATTEMPTS_AFTER_PAIRING)) |
1523 | 1510 | { |
1524 | 1511 | BTIF_TRACE_WARNING("%s:SDP failed after bonding re-attempting", __FUNCTION__); |
@@ -1543,37 +1530,21 @@ static void btif_dm_search_services_evt(UINT16 event, char *p_param) | ||
1543 | 1530 | /* onUuidChanged requires getBondedDevices to be populated. |
1544 | 1531 | ** bond_state_changed needs to be sent prior to remote_device_property |
1545 | 1532 | */ |
1546 | - if ((pairing_cb.state == BT_BOND_STATE_BONDED && pairing_cb.sdp_attempts) && | |
1533 | + if ((pairing_cb.state == BT_BOND_STATE_BONDING) && | |
1547 | 1534 | ((bdcmp(p_data->disc_res.bd_addr, pairing_cb.bd_addr) == 0) || |
1548 | - (bdcmp(p_data->disc_res.bd_addr, pairing_cb.static_bdaddr.address) == 0))) | |
1535 | + (bdcmp(p_data->disc_res.bd_addr, pairing_cb.static_bdaddr.address) == 0)) && | |
1536 | + pairing_cb.sdp_attempts > 0) | |
1549 | 1537 | { |
1550 | - LOG_INFO(LOG_TAG, "%s Remote Service SDP done.", __FUNCTION__); | |
1538 | + BTIF_TRACE_DEBUG("%s Remote Service SDP done. Call bond_state_changed_cb BONDED", | |
1539 | + __FUNCTION__); | |
1551 | 1540 | pairing_cb.sdp_attempts = 0; |
1552 | 1541 | |
1553 | - // Both SDP and bonding are done, clear pairing control block | |
1554 | - memset(&pairing_cb, 0, sizeof(pairing_cb)); | |
1555 | - | |
1556 | - // Send one empty UUID to Java to unblock pairing intent when SDP failed | |
1557 | - // or no UUID is discovered | |
1558 | - if (p_data->disc_res.result == BTA_SUCCESS || | |
1559 | - p_data->disc_res.num_uuids == 0) { | |
1560 | - LOG_INFO(LOG_TAG, "%s: SDP failed, send empty UUID to unblock bonding", | |
1561 | - __func__); | |
1562 | - bt_property_t prop; | |
1563 | - bt_uuid_t uuid = {}; | |
1564 | - char uuid_str[128] = UUID_EMPTY; | |
1565 | - | |
1566 | - string_to_uuid(uuid_str, &uuid); | |
1567 | - | |
1568 | - prop.type = BT_PROPERTY_UUIDS; | |
1569 | - prop.val = uuid.uu; | |
1570 | - prop.len = MAX_UUID_SIZE; | |
1542 | + // If bonding occured due to cross-key pairing, send bonding callback | |
1543 | + // for static address now | |
1544 | + if (bdcmp(p_data->disc_res.bd_addr, pairing_cb.static_bdaddr.address) == 0) | |
1545 | + bond_state_changed(BT_STATUS_SUCCESS, &bd_addr, BT_BOND_STATE_BONDING); | |
1571 | 1546 | |
1572 | - /* Send the event to the BTIF */ | |
1573 | - HAL_CBACK(bt_hal_cbacks, remote_device_properties_cb, | |
1574 | - BT_STATUS_SUCCESS, &bd_addr, 1, &prop); | |
1575 | - break; | |
1576 | - } | |
1547 | + bond_state_changed(BT_STATUS_SUCCESS, &bd_addr, BT_BOND_STATE_BONDED); | |
1577 | 1548 | } |
1578 | 1549 | |
1579 | 1550 | if (p_data->disc_res.num_uuids != 0) |
@@ -1797,7 +1768,7 @@ static void btif_dm_upstreams_evt(UINT16 event, char* p_param) | ||
1797 | 1768 | break; |
1798 | 1769 | |
1799 | 1770 | case BTA_DM_BOND_CANCEL_CMPL_EVT: |
1800 | - if (is_bonding_or_sdp()) | |
1771 | + if (pairing_cb.state == BT_BOND_STATE_BONDING) | |
1801 | 1772 | { |
1802 | 1773 | bdcpy(bd_addr.address, pairing_cb.bd_addr); |
1803 | 1774 | btm_set_bond_type_dev(pairing_cb.bd_addr, BOND_TYPE_UNKNOWN); |
@@ -2464,7 +2435,7 @@ bt_status_t btif_dm_cancel_bond(const bt_bdaddr_t *bd_addr) | ||
2464 | 2435 | ** 1. Restore scan modes |
2465 | 2436 | ** 2. special handling for HID devices |
2466 | 2437 | */ |
2467 | - if (is_bonding_or_sdp()) | |
2438 | + if (pairing_cb.state == BT_BOND_STATE_BONDING) | |
2468 | 2439 | { |
2469 | 2440 | |
2470 | 2441 | #if (defined(BLE_INCLUDED) && (BLE_INCLUDED == TRUE)) |
@@ -2526,7 +2497,7 @@ bt_status_t btif_dm_cancel_bond(const bt_bdaddr_t *bd_addr) | ||
2526 | 2497 | |
2527 | 2498 | void btif_dm_hh_open_failed(bt_bdaddr_t *bdaddr) |
2528 | 2499 | { |
2529 | - if (is_bonding_or_sdp() && | |
2500 | + if (pairing_cb.state == BT_BOND_STATE_BONDING && | |
2530 | 2501 | bdcmp(bdaddr->address, pairing_cb.bd_addr) == 0) |
2531 | 2502 | { |
2532 | 2503 | bond_state_changed(BT_STATUS_FAIL, bdaddr, BT_BOND_STATE_NONE); |
@@ -3166,11 +3137,6 @@ static void btif_dm_ble_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl) | ||
3166 | 3137 | break; |
3167 | 3138 | } |
3168 | 3139 | } |
3169 | - if (state == BT_BOND_STATE_BONDED && | |
3170 | - (bdcmp(bd_addr.address, pairing_cb.static_bdaddr.address) != 0)) { | |
3171 | - // Report RPA bonding state to Java in crosskey paring | |
3172 | - bond_state_changed(status, &bd_addr, BT_BOND_STATE_BONDING); | |
3173 | - } | |
3174 | 3140 | bond_state_changed(status, &bd_addr, state); |
3175 | 3141 | } |
3176 | 3142 |
@@ -3521,7 +3487,7 @@ bt_status_t btif_le_test_mode(uint16_t opcode, uint8_t *buf, uint8_t len) | ||
3521 | 3487 | void btif_dm_on_disable() |
3522 | 3488 | { |
3523 | 3489 | /* cancel any pending pairing requests */ |
3524 | - if (is_bonding_or_sdp()) | |
3490 | + if (pairing_cb.state == BT_BOND_STATE_BONDING) | |
3525 | 3491 | { |
3526 | 3492 | bt_bdaddr_t bd_addr; |
3527 | 3493 |