• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

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

system/bt


Commit MetaInfo

修訂7f531dbf2ba52e4bfdb130db2166b462b446b6e0 (tree)
時間2019-06-05 01:39:19
作者TreeHugger Robot <treehugger-gerrit@goog...>
CommiterAndroid (Google) Code Review

Log Message

Merge changes from topic "am-d2784a9e-cd2f-4414-b4db-f53b523a7b87" into nyc-mr2-dev

* changes:

[automerger] DO NOT MERGE Separate SDP procedure from bonding state (1/2) am: 553eb90719 am: fffbd1d3b0 am: db47d7e348 am: 6976e5f214
[automerger] DO NOT MERGE Separate SDP procedure from bonding state (1/2) am: 553eb90719 am: fffbd1d3b0 am: db47d7e348
[automerger] DO NOT MERGE Separate SDP procedure from bonding state (1/2) am: 553eb90719 am: fffbd1d3b0
[automerger] DO NOT MERGE Separate SDP procedure from bonding state (1/2) am: 553eb90719
DO NOT MERGE Separate SDP procedure from bonding state (1/2)

Change Summary

差異

--- 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
@@ -270,6 +271,11 @@ static bool is_empty_128bit(uint8_t *data)
270271 return !memcmp(zero, data, sizeof(zero));
271272 }
272273
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+
273279 static void btif_dm_data_copy(uint16_t event, char *dst, char *src)
274280 {
275281 tBTA_DM_SEC *dst_dm_sec = (tBTA_DM_SEC*)dst;
@@ -551,15 +557,14 @@ static void bond_state_changed(bt_status_t status, bt_bdaddr_t *bd_addr, bt_bond
551557
552558 HAL_CBACK(bt_hal_cbacks, bond_state_changed_cb, status, bd_addr, state);
553559
554- if (state == BT_BOND_STATE_BONDING)
560+ if (state == BT_BOND_STATE_BONDING ||
561+ (state == BT_BOND_STATE_BONDED && pairing_cb.sdp_attempts > 0))
555562 {
563+ // Save state for the device is bonding or SDP.
556564 pairing_cb.state = state;
557565 bdcpy(pairing_cb.bd_addr, bd_addr->address);
558566 } else {
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__);
567+ memset(&pairing_cb, 0, sizeof(pairing_cb));
563568 }
564569 }
565570
@@ -1187,6 +1192,14 @@ static void btif_dm_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
11871192
11881193 // Ensure inquiry is stopped before attempting service discovery
11891194 btif_dm_cancel_discovery();
1195+ if (is_crosskey) {
1196+ // If bonding occurred due to cross-key pairing, send bonding callback
1197+ // for static address now
1198+ LOG_INFO(LOG_TAG,
1199+ "%s: send bonding state update for static address", __func__);
1200+ bond_state_changed(BT_STATUS_SUCCESS, &bd_addr, BT_BOND_STATE_BONDING);
1201+ }
1202+ bond_state_changed(BT_STATUS_SUCCESS, &bd_addr, BT_BOND_STATE_BONDED);
11901203
11911204 /* Trigger SDP on the device */
11921205 pairing_cb.sdp_attempts = 1;
@@ -1480,7 +1493,7 @@ static void btif_dm_search_services_evt(UINT16 event, char *p_param)
14801493 BTIF_TRACE_DEBUG("%s:(result=0x%x, services 0x%x)", __FUNCTION__,
14811494 p_data->disc_res.result, p_data->disc_res.services);
14821495 if ((p_data->disc_res.result != BTA_SUCCESS) &&
1483- (pairing_cb.state == BT_BOND_STATE_BONDING ) &&
1496+ (pairing_cb.state == BT_BOND_STATE_BONDED) &&
14841497 (pairing_cb.sdp_attempts < BTIF_DM_MAX_SDP_ATTEMPTS_AFTER_PAIRING))
14851498 {
14861499 BTIF_TRACE_WARNING("%s:SDP failed after bonding re-attempting", __FUNCTION__);
@@ -1505,21 +1518,37 @@ static void btif_dm_search_services_evt(UINT16 event, char *p_param)
15051518 /* onUuidChanged requires getBondedDevices to be populated.
15061519 ** bond_state_changed needs to be sent prior to remote_device_property
15071520 */
1508- if ((pairing_cb.state == BT_BOND_STATE_BONDING) &&
1521+ if ((pairing_cb.state == BT_BOND_STATE_BONDED && pairing_cb.sdp_attempts) &&
15091522 ((bdcmp(p_data->disc_res.bd_addr, pairing_cb.bd_addr) == 0) ||
1510- (bdcmp(p_data->disc_res.bd_addr, pairing_cb.static_bdaddr.address) == 0)) &&
1511- pairing_cb.sdp_attempts > 0)
1523+ (bdcmp(p_data->disc_res.bd_addr, pairing_cb.static_bdaddr.address) == 0)))
15121524 {
1513- BTIF_TRACE_DEBUG("%s Remote Service SDP done. Call bond_state_changed_cb BONDED",
1514- __FUNCTION__);
1525+ LOG_INFO(LOG_TAG, "%s Remote Service SDP done.", __FUNCTION__);
15151526 pairing_cb.sdp_attempts = 0;
15161527
1517- // If bonding occured due to cross-key pairing, send bonding callback
1518- // for static address now
1519- if (bdcmp(p_data->disc_res.bd_addr, pairing_cb.static_bdaddr.address) == 0)
1520- bond_state_changed(BT_STATUS_SUCCESS, &bd_addr, BT_BOND_STATE_BONDING);
1528+ // Both SDP and bonding are done, clear pairing control block
1529+ memset(&pairing_cb, 0, sizeof(pairing_cb));
1530+
1531+ // Send one empty UUID to Java to unblock pairing intent when SDP failed
1532+ // or no UUID is discovered
1533+ if (p_data->disc_res.result == BTA_SUCCESS ||
1534+ p_data->disc_res.num_uuids == 0) {
1535+ LOG_INFO(LOG_TAG, "%s: SDP failed, send empty UUID to unblock bonding",
1536+ __func__);
1537+ bt_property_t prop;
1538+ bt_uuid_t uuid = {};
1539+ char uuid_str[128] = UUID_EMPTY;
15211540
1522- bond_state_changed(BT_STATUS_SUCCESS, &bd_addr, BT_BOND_STATE_BONDED);
1541+ string_to_uuid(uuid_str, &uuid);
1542+
1543+ prop.type = BT_PROPERTY_UUIDS;
1544+ prop.val = uuid.uu;
1545+ prop.len = MAX_UUID_SIZE;
1546+
1547+ /* Send the event to the BTIF */
1548+ HAL_CBACK(bt_hal_cbacks, remote_device_properties_cb,
1549+ BT_STATUS_SUCCESS, &bd_addr, 1, &prop);
1550+ break;
1551+ }
15231552 }
15241553
15251554 if (p_data->disc_res.num_uuids != 0)
@@ -1743,7 +1772,7 @@ static void btif_dm_upstreams_evt(UINT16 event, char* p_param)
17431772 break;
17441773
17451774 case BTA_DM_BOND_CANCEL_CMPL_EVT:
1746- if (pairing_cb.state == BT_BOND_STATE_BONDING)
1775+ if (is_bonding_or_sdp())
17471776 {
17481777 bdcpy(bd_addr.address, pairing_cb.bd_addr);
17491778 btm_set_bond_type_dev(pairing_cb.bd_addr, BOND_TYPE_UNKNOWN);
@@ -2410,7 +2439,7 @@ bt_status_t btif_dm_cancel_bond(const bt_bdaddr_t *bd_addr)
24102439 ** 1. Restore scan modes
24112440 ** 2. special handling for HID devices
24122441 */
2413- if (pairing_cb.state == BT_BOND_STATE_BONDING)
2442+ if (is_bonding_or_sdp())
24142443 {
24152444
24162445 #if (defined(BLE_INCLUDED) && (BLE_INCLUDED == TRUE))
@@ -2472,7 +2501,7 @@ bt_status_t btif_dm_cancel_bond(const bt_bdaddr_t *bd_addr)
24722501
24732502 void btif_dm_hh_open_failed(bt_bdaddr_t *bdaddr)
24742503 {
2475- if (pairing_cb.state == BT_BOND_STATE_BONDING &&
2504+ if (is_bonding_or_sdp() &&
24762505 bdcmp(bdaddr->address, pairing_cb.bd_addr) == 0)
24772506 {
24782507 bond_state_changed(BT_STATUS_FAIL, bdaddr, BT_BOND_STATE_NONE);
@@ -3112,6 +3141,11 @@ static void btif_dm_ble_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
31123141 break;
31133142 }
31143143 }
3144+ if (state == BT_BOND_STATE_BONDED &&
3145+ (bdcmp(bd_addr.address, pairing_cb.static_bdaddr.address) != 0)) {
3146+ // Report RPA bonding state to Java in crosskey paring
3147+ bond_state_changed(status, &bd_addr, BT_BOND_STATE_BONDING);
3148+ }
31153149 bond_state_changed(status, &bd_addr, state);
31163150 }
31173151
@@ -3462,7 +3496,7 @@ bt_status_t btif_le_test_mode(uint16_t opcode, uint8_t *buf, uint8_t len)
34623496 void btif_dm_on_disable()
34633497 {
34643498 /* cancel any pending pairing requests */
3465- if (pairing_cb.state == BT_BOND_STATE_BONDING)
3499+ if (is_bonding_or_sdp())
34663500 {
34673501 bt_bdaddr_t bd_addr;
34683502