// Do not call bond_state_changed_cb yet. Wait until remote service
// discovery is complete
} else {
+ bool is_bonded_device_removed = false;
// Map the HCI fail reason to bt status
switch (p_auth_cmpl->fail_reason) {
case HCI_ERR_PAGE_TIMEOUT:
break;
case HCI_ERR_PAIRING_NOT_ALLOWED:
- btif_storage_remove_bonded_device(&bd_addr);
+ is_bonded_device_removed =
+ (btif_storage_remove_bonded_device(&bd_addr) == BT_STATUS_SUCCESS);
status = BT_STATUS_AUTH_REJECTED;
break;
/* map the auth failure codes, so we can retry pairing if necessary */
case HCI_ERR_AUTH_FAILURE:
case HCI_ERR_KEY_MISSING:
- btif_storage_remove_bonded_device(&bd_addr);
+ is_bonded_device_removed =
+ (btif_storage_remove_bonded_device(&bd_addr) == BT_STATUS_SUCCESS);
[[fallthrough]];
case HCI_ERR_HOST_REJECT_SECURITY:
case HCI_ERR_ENCRY_MODE_NOT_ACCEPTABLE:
/* Remove Device as bonded in nvram as authentication failed */
BTIF_TRACE_DEBUG("%s(): removing hid pointing device from nvram",
__func__);
- btif_storage_remove_bonded_device(&bd_addr);
+ is_bonded_device_removed =
+ (btif_storage_remove_bonded_device(&bd_addr) == BT_STATUS_SUCCESS);
+ }
+ // Report bond state change to java only if we are bonding to a device or
+ // a device is removed from the pairing list.
+ if (pairing_cb.state == BT_BOND_STATE_BONDING || is_bonded_device_removed) {
+ bond_state_changed(status, bd_addr, state);
}
- bond_state_changed(status, bd_addr, state);
}
}