system/bt
Revisão | a33cdf2c9e66670be984ae0f99de6f04654b55e0 (tree) |
---|---|
Hora | 2019-06-05 01:39:19 |
Autor | TreeHugger Robot <treehugger-gerrit@goog...> |
Commiter | Android (Google) Code Review |
Merge changes from topic "am-d2784a9e-cd2f-4414-b4db-f53b523a7b87" into nyc-mr1-dev
* changes:
@@ -191,6 +191,7 @@ 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" | |
194 | 195 | |
195 | 196 | #define MAX_BTIF_BOND_EVENT_ENTRIES 15 |
196 | 197 |
@@ -269,6 +270,11 @@ static bool is_empty_128bit(uint8_t *data) | ||
269 | 270 | return !memcmp(zero, data, sizeof(zero)); |
270 | 271 | } |
271 | 272 | |
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 | + | |
272 | 278 | static void btif_dm_data_copy(uint16_t event, char *dst, char *src) |
273 | 279 | { |
274 | 280 | 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 | ||
550 | 556 | |
551 | 557 | HAL_CBACK(bt_hal_cbacks, bond_state_changed_cb, status, bd_addr, state); |
552 | 558 | |
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)) | |
554 | 561 | { |
562 | + // Save state for the device is bonding or SDP. | |
555 | 563 | pairing_cb.state = state; |
556 | 564 | bdcpy(pairing_cb.bd_addr, bd_addr->address); |
557 | 565 | } 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)); | |
562 | 567 | } |
563 | 568 | } |
564 | 569 |
@@ -1178,6 +1183,14 @@ static void btif_dm_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl) | ||
1178 | 1183 | |
1179 | 1184 | // Ensure inquiry is stopped before attempting service discovery |
1180 | 1185 | 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); | |
1181 | 1194 | |
1182 | 1195 | /* Trigger SDP on the device */ |
1183 | 1196 | pairing_cb.sdp_attempts = 1; |
@@ -1471,7 +1484,7 @@ static void btif_dm_search_services_evt(UINT16 event, char *p_param) | ||
1471 | 1484 | BTIF_TRACE_DEBUG("%s:(result=0x%x, services 0x%x)", __FUNCTION__, |
1472 | 1485 | p_data->disc_res.result, p_data->disc_res.services); |
1473 | 1486 | if ((p_data->disc_res.result != BTA_SUCCESS) && |
1474 | - (pairing_cb.state == BT_BOND_STATE_BONDING ) && | |
1487 | + (pairing_cb.state == BT_BOND_STATE_BONDED) && | |
1475 | 1488 | (pairing_cb.sdp_attempts < BTIF_DM_MAX_SDP_ATTEMPTS_AFTER_PAIRING)) |
1476 | 1489 | { |
1477 | 1490 | 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) | ||
1496 | 1509 | /* onUuidChanged requires getBondedDevices to be populated. |
1497 | 1510 | ** bond_state_changed needs to be sent prior to remote_device_property |
1498 | 1511 | */ |
1499 | - if ((pairing_cb.state == BT_BOND_STATE_BONDING) && | |
1512 | + if ((pairing_cb.state == BT_BOND_STATE_BONDED && pairing_cb.sdp_attempts) && | |
1500 | 1513 | ((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))) | |
1503 | 1515 | { |
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__); | |
1506 | 1517 | pairing_cb.sdp_attempts = 0; |
1507 | 1518 | |
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; | |
1512 | 1531 | |
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 | + } | |
1514 | 1543 | } |
1515 | 1544 | |
1516 | 1545 | if (p_data->disc_res.num_uuids != 0) |
@@ -1734,7 +1763,7 @@ static void btif_dm_upstreams_evt(UINT16 event, char* p_param) | ||
1734 | 1763 | break; |
1735 | 1764 | |
1736 | 1765 | case BTA_DM_BOND_CANCEL_CMPL_EVT: |
1737 | - if (pairing_cb.state == BT_BOND_STATE_BONDING) | |
1766 | + if (is_bonding_or_sdp()) | |
1738 | 1767 | { |
1739 | 1768 | bdcpy(bd_addr.address, pairing_cb.bd_addr); |
1740 | 1769 | btm_set_bond_type_dev(pairing_cb.bd_addr, BOND_TYPE_UNKNOWN); |
@@ -2384,7 +2413,7 @@ bt_status_t btif_dm_cancel_bond(const bt_bdaddr_t *bd_addr) | ||
2384 | 2413 | ** 1. Restore scan modes |
2385 | 2414 | ** 2. special handling for HID devices |
2386 | 2415 | */ |
2387 | - if (pairing_cb.state == BT_BOND_STATE_BONDING) | |
2416 | + if (is_bonding_or_sdp()) | |
2388 | 2417 | { |
2389 | 2418 | |
2390 | 2419 | #if (defined(BLE_INCLUDED) && (BLE_INCLUDED == TRUE)) |
@@ -2446,7 +2475,7 @@ bt_status_t btif_dm_cancel_bond(const bt_bdaddr_t *bd_addr) | ||
2446 | 2475 | |
2447 | 2476 | void btif_dm_hh_open_failed(bt_bdaddr_t *bdaddr) |
2448 | 2477 | { |
2449 | - if (pairing_cb.state == BT_BOND_STATE_BONDING && | |
2478 | + if (is_bonding_or_sdp() && | |
2450 | 2479 | bdcmp(bdaddr->address, pairing_cb.bd_addr) == 0) |
2451 | 2480 | { |
2452 | 2481 | bond_state_changed(BT_STATUS_FAIL, bdaddr, BT_BOND_STATE_NONE); |
@@ -3079,6 +3108,11 @@ static void btif_dm_ble_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl) | ||
3079 | 3108 | break; |
3080 | 3109 | } |
3081 | 3110 | } |
3111 | + if (state == BT_BOND_STATE_BONDED && | |
3112 | + (bdcmp(bd_addr.address, pairing_cb.static_bdaddr.address) != 0)) { | |
3113 | + // Report RPA bonding state to Java in crosskey paring | |
3114 | + bond_state_changed(status, &bd_addr, BT_BOND_STATE_BONDING); | |
3115 | + } | |
3082 | 3116 | bond_state_changed(status, &bd_addr, state); |
3083 | 3117 | } |
3084 | 3118 |
@@ -3392,7 +3426,7 @@ bt_status_t btif_le_test_mode(uint16_t opcode, uint8_t *buf, uint8_t len) | ||
3392 | 3426 | void btif_dm_on_disable() |
3393 | 3427 | { |
3394 | 3428 | /* cancel any pending pairing requests */ |
3395 | - if (pairing_cb.state == BT_BOND_STATE_BONDING) | |
3429 | + if (is_bonding_or_sdp()) | |
3396 | 3430 | { |
3397 | 3431 | bt_bdaddr_t bd_addr; |
3398 | 3432 |