From 7d61fe4c1fb392c117115243ed7bad2c90f4ed34 Mon Sep 17 00:00:00 2001 From: Zach Johnson Date: Wed, 19 Aug 2020 11:43:39 -0700 Subject: [PATCH] Simplify BTM_SetConnectability The windows are fixed defaults, and need no validation. Bug: 159815595 Tag: #refactor Test: compile & verify basic functions working Change-Id: Ib3e5580af6d742333f2946d393d7bdcded7d9737 --- stack/btm/btm_inq.cc | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/stack/btm/btm_inq.cc b/stack/btm/btm_inq.cc index 623fa0c60..2a4c83ca0 100644 --- a/stack/btm/btm_inq.cc +++ b/stack/btm/btm_inq.cc @@ -372,8 +372,8 @@ tBTM_STATUS BTM_SetConnectability(uint16_t page_mode) { } uint8_t scan_mode = 0; - uint16_t window = 0; - uint16_t interval = 0; + uint16_t window = BTM_DEFAULT_CONN_WINDOW; + uint16_t interval = BTM_DEFAULT_CONN_INTERVAL; tBTM_INQUIRY_VAR_ST* p_inq = &btm_cb.btm_inq_vars; BTM_TRACE_API("BTM_SetConnectability"); @@ -394,26 +394,11 @@ tBTM_STATUS BTM_SetConnectability(uint16_t page_mode) { /* Make sure the controller is active */ if (!controller_get_interface()->get_is_ready()) return (BTM_DEV_RESET); - /* If the window and/or interval is '0', set to default values */ - if (!window) window = BTM_DEFAULT_CONN_WINDOW; - - if (!interval) interval = BTM_DEFAULT_CONN_INTERVAL; - - BTM_TRACE_API( - "BTM_SetConnectability: mode %d [NonConn-0, Conn-1], window 0x%04x, " - "interval 0x%04x", - page_mode, window, interval); + BTM_TRACE_API("BTM_SetConnectability: mode %d [NonConn-0, Conn-1]", + page_mode); - /*** Check for valid window and interval parameters ***/ /*** Only check window and duration if mode is connectable ***/ if (page_mode == BTM_CONNECTABLE) { - /* window must be less than or equal to interval */ - if (window < HCI_MIN_PAGESCAN_WINDOW || window > HCI_MAX_PAGESCAN_WINDOW || - interval < HCI_MIN_PAGESCAN_INTERVAL || - interval > HCI_MAX_PAGESCAN_INTERVAL || window > interval) { - return (BTM_ILLEGAL_VALUE); - } - scan_mode |= HCI_PAGE_SCAN_ENABLED; } -- 2.11.0