• 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

Revisãoa33cdf2c9e66670be984ae0f99de6f04654b55e0 (tree)
Hora2019-06-05 01:39:19
AutorTreeHugger Robot <treehugger-gerrit@goog...>
CommiterAndroid (Google) Code Review

Mensagem de Log

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

* changes:

[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)

Mudança Sumário

Diff

--- 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)
@@ -1734,7 +1763,7 @@ static void btif_dm_upstreams_evt(UINT16 event, char* p_param)
17341763 break;
17351764
17361765 case BTA_DM_BOND_CANCEL_CMPL_EVT:
1737- if (pairing_cb.state == BT_BOND_STATE_BONDING)
1766+ if (is_bonding_or_sdp())
17381767 {
17391768 bdcpy(bd_addr.address, pairing_cb.bd_addr);
17401769 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)
23842413 ** 1. Restore scan modes
23852414 ** 2. special handling for HID devices
23862415 */
2387- if (pairing_cb.state == BT_BOND_STATE_BONDING)
2416+ if (is_bonding_or_sdp())
23882417 {
23892418
23902419 #if (defined(BLE_INCLUDED) && (BLE_INCLUDED == TRUE))
@@ -2446,7 +2475,7 @@ bt_status_t btif_dm_cancel_bond(const bt_bdaddr_t *bd_addr)
24462475
24472476 void btif_dm_hh_open_failed(bt_bdaddr_t *bdaddr)
24482477 {
2449- if (pairing_cb.state == BT_BOND_STATE_BONDING &&
2478+ if (is_bonding_or_sdp() &&
24502479 bdcmp(bdaddr->address, pairing_cb.bd_addr) == 0)
24512480 {
24522481 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)
30793108 break;
30803109 }
30813110 }
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+ }
30823116 bond_state_changed(status, &bd_addr, state);
30833117 }
30843118
@@ -3392,7 +3426,7 @@ bt_status_t btif_le_test_mode(uint16_t opcode, uint8_t *buf, uint8_t len)
33923426 void btif_dm_on_disable()
33933427 {
33943428 /* cancel any pending pairing requests */
3395- if (pairing_cb.state == BT_BOND_STATE_BONDING)
3429+ if (is_bonding_or_sdp())
33963430 {
33973431 bt_bdaddr_t bd_addr;
33983432