• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

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

system/bt


Commit MetaInfo

Revision56cdedd92b1bccd35738f832bf97ac57c1dc2169 (tree)
Zeit2019-07-16 04:58:39
AutorArjun Garg <arjgarg@goog...>
CommiterArjun Garg

Log Message

Revert "DO NOT MERGE Separate SDP procedure from bonding state (1/2)"

This reverts commit 1df6bcbe986e783b486789d07afe35c47c2658ae.

Ändern Zusammenfassung

Diff

--- a/btif/src/btif_dm.cc
+++ b/btif/src/btif_dm.cc
@@ -183,7 +183,6 @@ typedef struct {
183183 #define BTA_SERVICE_ID_TO_SERVICE_MASK(id) (1 << (id))
184184
185185 #define UUID_HUMAN_INTERFACE_DEVICE "00001124-0000-1000-8000-00805f9b34fb"
186-#define UUID_EMPTY "00000000-0000-0000-0000-000000000000"
187186
188187 #define MAX_BTIF_BOND_EVENT_ENTRIES 15
189188
@@ -262,11 +261,6 @@ static bool is_empty_128bit(uint8_t* data) {
262261 return !memcmp(zero, data, sizeof(zero));
263262 }
264263
265-static bool is_bonding_or_sdp() {
266- return pairing_cb.state == BT_BOND_STATE_BONDING ||
267- (pairing_cb.state == BT_BOND_STATE_BONDED && pairing_cb.sdp_attempts);
268-}
269-
270264 static void btif_dm_data_copy(uint16_t event, char* dst, char* src) {
271265 tBTA_DM_SEC* dst_dm_sec = (tBTA_DM_SEC*)dst;
272266 tBTA_DM_SEC* src_dm_sec = (tBTA_DM_SEC*)src;
@@ -493,6 +487,8 @@ static void bond_state_changed(bt_status_t status, const RawAddress& bd_addr,
493487 bt_bond_state_t state) {
494488 btif_stats_add_bond_event(bd_addr, BTIF_DM_FUNC_BOND_STATE_CHANGED, state);
495489
490+ // Send bonding state only once - based on outgoing/incoming we may receive
491+ // duplicates
496492 if ((pairing_cb.state == state) && (state == BT_BOND_STATE_BONDING)) {
497493 // Cross key pairing so send callback for static address
498494 if (!pairing_cb.static_bdaddr.IsEmpty()) {
@@ -510,13 +506,14 @@ static void bond_state_changed(bt_status_t status, const RawAddress& bd_addr,
510506 auto tmp = bd_addr;
511507 HAL_CBACK(bt_hal_cbacks, bond_state_changed_cb, status, &tmp, state);
512508
513- if (state == BT_BOND_STATE_BONDING ||
514- (state == BT_BOND_STATE_BONDED && pairing_cb.sdp_attempts > 0)) {
515- // Save state for the device is bonding or SDP.
509+ if (state == BT_BOND_STATE_BONDING) {
516510 pairing_cb.state = state;
517511 pairing_cb.bd_addr = bd_addr;
518512 } else {
519- pairing_cb = {};
513+ if (!pairing_cb.sdp_attempts)
514+ memset(&pairing_cb, 0, sizeof(pairing_cb));
515+ else
516+ BTIF_TRACE_DEBUG("%s: BR-EDR service discovery active", __func__);
520517 }
521518 }
522519
@@ -1124,17 +1121,6 @@ static void btif_dm_auth_cmpl_evt(tBTA_DM_AUTH_CMPL* p_auth_cmpl) {
11241121
11251122 /* Trigger SDP on the device */
11261123 pairing_cb.sdp_attempts = 1;
1127-
1128- if (is_crosskey) {
1129- // If bonding occurred due to cross-key pairing, send bonding callback
1130- // for static address now
1131- LOG_INFO(LOG_TAG,
1132- "%s: send bonding state update for static address %s",
1133- __func__, bd_addr.ToString().c_str());
1134- bond_state_changed(BT_STATUS_SUCCESS, bd_addr, BT_BOND_STATE_BONDING);
1135- }
1136- bond_state_changed(BT_STATUS_SUCCESS, bd_addr, BT_BOND_STATE_BONDED);
1137-
11381124 btif_dm_get_remote_services(bd_addr);
11391125 }
11401126 }
@@ -1392,9 +1378,9 @@ static void btif_dm_search_services_evt(uint16_t event, char* p_param) {
13921378
13931379 BTIF_TRACE_DEBUG("%s:(result=0x%x, services 0x%x)", __func__,
13941380 p_data->disc_res.result, p_data->disc_res.services);
1395- if (p_data->disc_res.result != BTA_SUCCESS &&
1396- pairing_cb.state == BT_BOND_STATE_BONDED &&
1397- pairing_cb.sdp_attempts < BTIF_DM_MAX_SDP_ATTEMPTS_AFTER_PAIRING) {
1381+ if ((p_data->disc_res.result != BTA_SUCCESS) &&
1382+ (pairing_cb.state == BT_BOND_STATE_BONDING) &&
1383+ (pairing_cb.sdp_attempts < BTIF_DM_MAX_SDP_ATTEMPTS_AFTER_PAIRING)) {
13981384 BTIF_TRACE_WARNING("%s:SDP failed after bonding re-attempting",
13991385 __func__);
14001386 pairing_cb.sdp_attempts++;
@@ -1419,38 +1405,21 @@ static void btif_dm_search_services_evt(uint16_t event, char* p_param) {
14191405 /* onUuidChanged requires getBondedDevices to be populated.
14201406 ** bond_state_changed needs to be sent prior to remote_device_property
14211407 */
1422- if ((pairing_cb.state == BT_BOND_STATE_BONDED && pairing_cb.sdp_attempts) &&
1408+ if ((pairing_cb.state == BT_BOND_STATE_BONDING) &&
14231409 (p_data->disc_res.bd_addr == pairing_cb.bd_addr ||
1424- p_data->disc_res.bd_addr == pairing_cb.static_bdaddr)) {
1425- LOG_INFO(LOG_TAG, "%s: SDP search done for %s", __func__,
1426- bd_addr.ToString().c_str());
1410+ p_data->disc_res.bd_addr == pairing_cb.static_bdaddr) &&
1411+ pairing_cb.sdp_attempts > 0) {
1412+ BTIF_TRACE_DEBUG(
1413+ "%s Remote Service SDP done. Call bond_state_changed_cb BONDED",
1414+ __func__);
14271415 pairing_cb.sdp_attempts = 0;
14281416
1429- // Both SDP and bonding are done, clear pairing control block
1430- pairing_cb = {};
1431-
1432- // Send one empty UUID to Java to unblock pairing intent when SDP failed
1433- // or no UUID is discovered
1434- if (p_data->disc_res.result != BTA_SUCCESS ||
1435- p_data->disc_res.num_uuids == 0) {
1436- LOG_INFO(LOG_TAG,
1437- "%s: SDP failed, send empty UUID to unblock bonding %s",
1438- __func__, bd_addr.ToString().c_str());
1439- bt_property_t prop;
1440- bt_uuid_t uuid = {};
1441- char uuid_str[128] = UUID_EMPTY;
1442-
1443- string_to_uuid(uuid_str, &uuid);
1444-
1445- prop.type = BT_PROPERTY_UUIDS;
1446- prop.val = uuid.uu;
1447- prop.len = MAX_UUID_SIZE;
1448-
1449- /* Send the event to the BTIF */
1450- HAL_CBACK(bt_hal_cbacks, remote_device_properties_cb,
1451- BT_STATUS_SUCCESS, &bd_addr, 1, &prop);
1452- break;
1453- }
1417+ // If bonding occured due to cross-key pairing, send bonding callback
1418+ // for static address now
1419+ if (p_data->disc_res.bd_addr == pairing_cb.static_bdaddr)
1420+ bond_state_changed(BT_STATUS_SUCCESS, bd_addr, BT_BOND_STATE_BONDING);
1421+
1422+ bond_state_changed(BT_STATUS_SUCCESS, bd_addr, BT_BOND_STATE_BONDED);
14541423 }
14551424
14561425 if (p_data->disc_res.num_uuids != 0) {
@@ -1660,7 +1629,7 @@ static void btif_dm_upstreams_evt(uint16_t event, char* p_param) {
16601629 break;
16611630
16621631 case BTA_DM_BOND_CANCEL_CMPL_EVT:
1663- if (is_bonding_or_sdp()) {
1632+ if (pairing_cb.state == BT_BOND_STATE_BONDING) {
16641633 bd_addr = pairing_cb.bd_addr;
16651634 btm_set_bond_type_dev(pairing_cb.bd_addr, BOND_TYPE_UNKNOWN);
16661635 bond_state_changed((bt_status_t)p_data->bond_cancel_cmpl.result,
@@ -2308,7 +2277,7 @@ bt_status_t btif_dm_cancel_bond(const RawAddress* bd_addr) {
23082277 ** 1. Restore scan modes
23092278 ** 2. special handling for HID devices
23102279 */
2311- if (is_bonding_or_sdp()) {
2280+ if (pairing_cb.state == BT_BOND_STATE_BONDING) {
23122281 if (pairing_cb.is_ssp) {
23132282 if (pairing_cb.is_le_only) {
23142283 BTA_DmBleSecurityGrant(*bd_addr, BTA_DM_SEC_PAIR_NOT_SPT);
@@ -2500,7 +2469,7 @@ bt_status_t btif_dm_get_remote_services(const RawAddress& remote_addr) {
25002469
25012470 /*******************************************************************************
25022471 *
2503- * Function btif_dm_get_remote_services_by_transport
2472+ * Function btif_dm_get_remote_services_transport
25042473 *
25052474 * Description Start SDP to get remote services by transport
25062475 *
@@ -2892,10 +2861,6 @@ static void btif_dm_ble_auth_cmpl_evt(tBTA_DM_AUTH_CMPL* p_auth_cmpl) {
28922861 break;
28932862 }
28942863 }
2895- if (state == BT_BOND_STATE_BONDED && bd_addr != pairing_cb.static_bdaddr) {
2896- // Report RPA bonding state to Java in crosskey paring
2897- bond_state_changed(status, bd_addr, BT_BOND_STATE_BONDING);
2898- }
28992864 bond_state_changed(status, bd_addr, state);
29002865 }
29012866
@@ -3206,7 +3171,7 @@ bt_status_t btif_le_test_mode(uint16_t opcode, uint8_t* buf, uint8_t len) {
32063171
32073172 void btif_dm_on_disable() {
32083173 /* cancel any pending pairing requests */
3209- if (is_bonding_or_sdp()) {
3174+ if (pairing_cb.state == BT_BOND_STATE_BONDING) {
32103175 BTIF_TRACE_DEBUG("%s: Cancel pending pairing request", __func__);
32113176 btif_dm_cancel_bond(&pairing_cb.bd_addr);
32123177 }