Skip to content

Commit

Permalink
Revert "Revert "CHROMIUM: bluetooth: reset advertising intervals""
Browse files Browse the repository at this point in the history
This reverts commit f6794e6d752ddd9c183ecd7a3b3f4ef960fe7c99.

BUG=chromium:704196
TEST=Deploy v5.44 BlueZ system daemon with v4.9 BlueZ kernel on Nyan_Big and
perform automated tests (suite:bluetooth) and manual tests against mouses,
keyboards and headphones.

Change-Id: I63f79f7d7927faf34bfd7231488c2813f10011e2
Signed-off-by: Miao-chen Chou <[email protected]>
Reviewed-on: https://chromium-review.googlesource.com/480214
Tested-by: Shyh-In Hwang <[email protected]>
Reviewed-by: Shyh-In Hwang <[email protected]>
  • Loading branch information
mcchou-cr authored and chrome-bot committed Apr 28, 2017
1 parent b76f206 commit ee636e8
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions net/bluetooth/mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -4361,6 +4361,8 @@ static int set_advertising_intervals(struct sock *sk, struct hci_dev *hdev,
{
struct mgmt_cp_set_advertising_intervals *cp = data;
int err;
/* If both min_interval and max_interval are 0, use default values. */
bool use_default = cp->min_interval == 0 && cp->max_interval == 0;

BT_DBG("%s", hdev->name);

Expand All @@ -4371,19 +4373,25 @@ static int set_advertising_intervals(struct sock *sk, struct hci_dev *hdev,
MGMT_STATUS_REJECTED);

/* Check the validity of the intervals. */
if (cp->min_interval < HCI_VALID_LE_ADV_MIN_INTERVAL ||
cp->max_interval > HCI_VALID_LE_ADV_MAX_INTERVAL ||
cp->min_interval > cp->max_interval) {
if (!use_default && (cp->min_interval < HCI_VALID_LE_ADV_MIN_INTERVAL ||
cp->max_interval > HCI_VALID_LE_ADV_MAX_INTERVAL ||
cp->min_interval > cp->max_interval)) {
return mgmt_cmd_status(sk, hdev->id,
MGMT_OP_SET_ADVERTISING_INTERVALS,
MGMT_STATUS_INVALID_PARAMS);
}

hci_dev_lock(hdev);

hci_dev_set_flag(hdev, HCI_ADVERTISING_INTERVALS);
hdev->le_adv_min_interval = cp->min_interval;
hdev->le_adv_max_interval = cp->max_interval;
if (use_default) {
hci_dev_clear_flag(hdev, HCI_ADVERTISING_INTERVALS);
hdev->le_adv_min_interval = HCI_DEFAULT_LE_ADV_MIN_INTERVAL;
hdev->le_adv_max_interval = HCI_DEFAULT_LE_ADV_MAX_INTERVAL;
} else {
hci_dev_set_flag(hdev, HCI_ADVERTISING_INTERVALS);
hdev->le_adv_min_interval = cp->min_interval;
hdev->le_adv_max_interval = cp->max_interval;
}

/* Re-enable advertising only when it is already on. */
if (hci_dev_test_flag(hdev, HCI_LE_ADV)) {
Expand Down

0 comments on commit ee636e8

Please sign in to comment.