• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

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

system/bt


Commit MetaInfo

Révision613026555d21d4d8bc6ce7fe3bab0550c31243bc (tree)
l'heure2019-07-16 05:00:08
AuteurArjun Garg <arjgarg@goog...>
CommiterArjun Garg

Message de Log

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

This reverts commit 12df1a2282e6d591bd0e1db75f0c38067a31ef40.

Change Summary

Modification

--- a/btif/src/btif_dm.cc
+++ b/btif/src/btif_dm.cc
@@ -257,11 +257,6 @@ static bool is_empty_128bit(uint8_t* data) {
257257 return !memcmp(zero, data, sizeof(zero));
258258 }
259259
260-static bool is_bonding_or_sdp() {
261- return pairing_cb.state == BT_BOND_STATE_BONDING ||
262- (pairing_cb.state == BT_BOND_STATE_BONDED && pairing_cb.sdp_attempts);
263-}
264-
265260 static void btif_dm_data_copy(uint16_t event, char* dst, char* src) {
266261 tBTA_DM_SEC* dst_dm_sec = (tBTA_DM_SEC*)dst;
267262 tBTA_DM_SEC* src_dm_sec = (tBTA_DM_SEC*)src;
@@ -488,6 +483,8 @@ static void bond_state_changed(bt_status_t status, const RawAddress& bd_addr,
488483 bt_bond_state_t state) {
489484 btif_stats_add_bond_event(bd_addr, BTIF_DM_FUNC_BOND_STATE_CHANGED, state);
490485
486+ // Send bonding state only once - based on outgoing/incoming we may receive
487+ // duplicates
491488 if ((pairing_cb.state == state) && (state == BT_BOND_STATE_BONDING)) {
492489 // Cross key pairing so send callback for static address
493490 if (!pairing_cb.static_bdaddr.IsEmpty()) {
@@ -505,13 +502,14 @@ static void bond_state_changed(bt_status_t status, const RawAddress& bd_addr,
505502 auto tmp = bd_addr;
506503 HAL_CBACK(bt_hal_cbacks, bond_state_changed_cb, status, &tmp, state);
507504
508- if (state == BT_BOND_STATE_BONDING ||
509- (state == BT_BOND_STATE_BONDED && pairing_cb.sdp_attempts > 0)) {
510- // Save state for the device is bonding or SDP.
505+ if (state == BT_BOND_STATE_BONDING) {
511506 pairing_cb.state = state;
512507 pairing_cb.bd_addr = bd_addr;
513508 } else {
514- pairing_cb = {};
509+ if (!pairing_cb.sdp_attempts)
510+ memset(&pairing_cb, 0, sizeof(pairing_cb));
511+ else
512+ BTIF_TRACE_DEBUG("%s: BR-EDR service discovery active", __func__);
515513 }
516514 }
517515
@@ -1137,17 +1135,6 @@ static void btif_dm_auth_cmpl_evt(tBTA_DM_AUTH_CMPL* p_auth_cmpl) {
11371135
11381136 /* Trigger SDP on the device */
11391137 pairing_cb.sdp_attempts = 1;
1140-
1141- if (is_crosskey) {
1142- // If bonding occurred due to cross-key pairing, send bonding callback
1143- // for static address now
1144- LOG_INFO(LOG_TAG,
1145- "%s: send bonding state update for static address %s",
1146- __func__, bd_addr.ToString().c_str());
1147- bond_state_changed(BT_STATUS_SUCCESS, bd_addr, BT_BOND_STATE_BONDING);
1148- }
1149- bond_state_changed(BT_STATUS_SUCCESS, bd_addr, BT_BOND_STATE_BONDED);
1150-
11511138 btif_dm_get_remote_services(bd_addr);
11521139 }
11531140 }
@@ -1405,9 +1392,9 @@ static void btif_dm_search_services_evt(uint16_t event, char* p_param) {
14051392
14061393 BTIF_TRACE_DEBUG("%s:(result=0x%x, services 0x%x)", __func__,
14071394 p_data->disc_res.result, p_data->disc_res.services);
1408- if (p_data->disc_res.result != BTA_SUCCESS &&
1409- pairing_cb.state == BT_BOND_STATE_BONDED &&
1410- pairing_cb.sdp_attempts < BTIF_DM_MAX_SDP_ATTEMPTS_AFTER_PAIRING) {
1395+ if ((p_data->disc_res.result != BTA_SUCCESS) &&
1396+ (pairing_cb.state == BT_BOND_STATE_BONDING) &&
1397+ (pairing_cb.sdp_attempts < BTIF_DM_MAX_SDP_ATTEMPTS_AFTER_PAIRING)) {
14111398 BTIF_TRACE_WARNING("%s:SDP failed after bonding re-attempting",
14121399 __func__);
14131400 pairing_cb.sdp_attempts++;
@@ -1429,35 +1416,21 @@ static void btif_dm_search_services_evt(uint16_t event, char* p_param) {
14291416 /* onUuidChanged requires getBondedDevices to be populated.
14301417 ** bond_state_changed needs to be sent prior to remote_device_property
14311418 */
1432- if (pairing_cb.state == BT_BOND_STATE_BONDED && pairing_cb.sdp_attempts &&
1419+ if ((pairing_cb.state == BT_BOND_STATE_BONDING) &&
14331420 (p_data->disc_res.bd_addr == pairing_cb.bd_addr ||
1434- p_data->disc_res.bd_addr == pairing_cb.static_bdaddr)) {
1435- LOG_INFO(LOG_TAG, "%s: SDP search done for %s", __func__,
1436- bd_addr.ToString().c_str());
1421+ p_data->disc_res.bd_addr == pairing_cb.static_bdaddr) &&
1422+ pairing_cb.sdp_attempts > 0) {
1423+ BTIF_TRACE_DEBUG(
1424+ "%s Remote Service SDP done. Call bond_state_changed_cb BONDED",
1425+ __func__);
14371426 pairing_cb.sdp_attempts = 0;
14381427
1439- // Both SDP and bonding are done, clear pairing control block
1440- pairing_cb = {};
1441-
1442- // Send one empty UUID to Java to unblock pairing intent when SDP failed
1443- // or no UUID is discovered
1444- if (p_data->disc_res.result != BTA_SUCCESS ||
1445- p_data->disc_res.num_uuids == 0) {
1446- LOG_INFO(LOG_TAG,
1447- "%s: SDP failed, send empty UUID to unblock bonding %s",
1448- __func__, bd_addr.ToString().c_str());
1449- bt_property_t prop;
1450- Uuid uuid = {};
1451-
1452- prop.type = BT_PROPERTY_UUIDS;
1453- prop.val = &uuid;
1454- prop.len = Uuid::kNumBytes128;
1455-
1456- /* Send the event to the BTIF */
1457- HAL_CBACK(bt_hal_cbacks, remote_device_properties_cb,
1458- BT_STATUS_SUCCESS, &bd_addr, 1, &prop);
1459- break;
1460- }
1428+ // If bonding occured due to cross-key pairing, send bonding callback
1429+ // for static address now
1430+ if (p_data->disc_res.bd_addr == pairing_cb.static_bdaddr)
1431+ bond_state_changed(BT_STATUS_SUCCESS, bd_addr, BT_BOND_STATE_BONDING);
1432+
1433+ bond_state_changed(BT_STATUS_SUCCESS, bd_addr, BT_BOND_STATE_BONDED);
14611434 }
14621435
14631436 if (p_data->disc_res.num_uuids != 0) {
@@ -1652,7 +1625,7 @@ static void btif_dm_upstreams_evt(uint16_t event, char* p_param) {
16521625 break;
16531626
16541627 case BTA_DM_BOND_CANCEL_CMPL_EVT:
1655- if (is_bonding_or_sdp()) {
1628+ if (pairing_cb.state == BT_BOND_STATE_BONDING) {
16561629 bd_addr = pairing_cb.bd_addr;
16571630 btm_set_bond_type_dev(pairing_cb.bd_addr, BOND_TYPE_UNKNOWN);
16581631 bond_state_changed((bt_status_t)p_data->bond_cancel_cmpl.result,
@@ -2295,7 +2268,7 @@ bt_status_t btif_dm_cancel_bond(const RawAddress* bd_addr) {
22952268 ** 1. Restore scan modes
22962269 ** 2. special handling for HID devices
22972270 */
2298- if (is_bonding_or_sdp()) {
2271+ if (pairing_cb.state == BT_BOND_STATE_BONDING) {
22992272 if (pairing_cb.is_ssp) {
23002273 if (pairing_cb.is_le_only) {
23012274 BTA_DmBleSecurityGrant(*bd_addr, BTA_DM_SEC_PAIR_NOT_SPT);
@@ -2493,7 +2466,7 @@ bt_status_t btif_dm_get_remote_services(const RawAddress& remote_addr) {
24932466
24942467 /*******************************************************************************
24952468 *
2496- * Function btif_dm_get_remote_services_by_transport
2469+ * Function btif_dm_get_remote_services_transport
24972470 *
24982471 * Description Start SDP to get remote services by transport
24992472 *
@@ -2880,10 +2853,6 @@ static void btif_dm_ble_auth_cmpl_evt(tBTA_DM_AUTH_CMPL* p_auth_cmpl) {
28802853 break;
28812854 }
28822855 }
2883- if (state == BT_BOND_STATE_BONDED && bd_addr != pairing_cb.static_bdaddr) {
2884- // Report RPA bonding state to Java in crosskey paring
2885- bond_state_changed(status, bd_addr, BT_BOND_STATE_BONDING);
2886- }
28872856 bond_state_changed(status, bd_addr, state);
28882857 }
28892858
@@ -3194,7 +3163,7 @@ bt_status_t btif_le_test_mode(uint16_t opcode, uint8_t* buf, uint8_t len) {
31943163
31953164 void btif_dm_on_disable() {
31963165 /* cancel any pending pairing requests */
3197- if (is_bonding_or_sdp()) {
3166+ if (pairing_cb.state == BT_BOND_STATE_BONDING) {
31983167 BTIF_TRACE_DEBUG("%s: Cancel pending pairing request", __func__);
31993168 btif_dm_cancel_bond(&pairing_cb.bd_addr);
32003169 }