Loading system/stack/btm/btm_ble_bgconn.cc +8 −2 Original line number Diff line number Diff line Loading @@ -173,6 +173,13 @@ bool BTM_BackgroundConnectAddressKnown(const RawAddress& address) { /** Adds the device into acceptlist. Returns false if acceptlist is full and * device can't be added, true otherwise. */ bool BTM_AcceptlistAdd(const RawAddress& address) { return BTM_AcceptlistAdd(address, false); } /** Adds the device into acceptlist and indicates whether to using direct * connect parameters. Returns false if acceptlist is full and device can't * be added, true otherwise. */ bool BTM_AcceptlistAdd(const RawAddress& address, bool is_direct) { if (!controller_get_interface()->supports_ble()) { LOG_WARN("Controller does not support Le"); return false; Loading @@ -181,8 +188,7 @@ bool BTM_AcceptlistAdd(const RawAddress& address) { tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(address); return bluetooth::shim::ACL_AcceptLeConnectionFrom( convert_to_address_with_type(address, p_dev_rec), /* is_direct */ false); convert_to_address_with_type(address, p_dev_rec), is_direct); } /** Removes the device from acceptlist */ Loading system/stack/btm/btm_ble_bgconn.h +5 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,11 @@ * device can't be added, true otherwise. */ extern bool BTM_AcceptlistAdd(const RawAddress& address); /** Adds the device into acceptlist and indicates whether to using direct * connect parameters. Returns false if acceptlist is full and device can't * be added, true otherwise. */ extern bool BTM_AcceptlistAdd(const RawAddress& address, bool is_direct); /** Removes the device from acceptlist */ extern void BTM_AcceptlistRemove(const RawAddress& address); Loading system/stack/gatt/connection_manager.cc +2 −2 Original line number Diff line number Diff line Loading @@ -464,7 +464,7 @@ void wl_direct_connect_timeout_cb(uint8_t app_id, const RawAddress& address) { direct_connect_remove(app_id, address); } /** Add a device to the direcgt connection list. Returns true if device /** Add a device to the direct connection list. Returns true if device * added to the list, false otherwise */ bool direct_connect_add(uint8_t app_id, const RawAddress& address) { LOG_DEBUG("app_id=%d, address=%s", static_cast<int>(app_id), Loading Loading @@ -492,7 +492,7 @@ bool direct_connect_add(uint8_t app_id, const RawAddress& address) { } if (!in_acceptlist) { if (!BTM_AcceptlistAdd(address)) { if (!BTM_AcceptlistAdd(address, true)) { // if we can't add to acceptlist, turn parameters back to slow. LOG_WARN("Unable to add le device to acceptlist"); return false; Loading system/stack/test/gatt_connection_manager_test.cc +10 −5 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ namespace { class AcceptlistMock { public: MOCK_METHOD1(AcceptlistAdd, bool(const RawAddress&)); MOCK_METHOD2(AcceptlistAdd, bool(const RawAddress&, bool is_direct)); MOCK_METHOD1(AcceptlistRemove, void(const RawAddress&)); MOCK_METHOD0(AcceptlistClear, void()); MOCK_METHOD2(OnConnectionTimedOut, void(uint8_t, const RawAddress&)); Loading @@ -57,6 +58,10 @@ bool BTM_AcceptlistAdd(const RawAddress& address) { return localAcceptlistMock->AcceptlistAdd(address); } bool BTM_AcceptlistAdd(const RawAddress& address, bool is_direct) { return localAcceptlistMock->AcceptlistAdd(address, is_direct); } void BTM_AcceptlistRemove(const RawAddress& address) { return localAcceptlistMock->AcceptlistRemove(address); } Loading Loading @@ -166,7 +171,7 @@ TEST_F(BleConnectionManager, test_background_connection_multiple_clients) { TEST_F(BleConnectionManager, test_direct_connection_client) { // Direct connect attempt: use faster scan parameters, add to acceptlist, // start 30 timeout EXPECT_CALL(*localAcceptlistMock, AcceptlistAdd(address1)) EXPECT_CALL(*localAcceptlistMock, AcceptlistAdd(address1, true)) .WillOnce(Return(true)); EXPECT_CALL(*localAcceptlistMock, AcceptlistRemove(_)).Times(0); EXPECT_CALL(*AlarmMock::Get(), AlarmNew(_)).Times(1); Loading Loading @@ -195,7 +200,7 @@ TEST_F(BleConnectionManager, test_direct_connection_client) { /** Verify direct connection timeout does remove device from acceptlist, and * lower the connection scan parameters */ TEST_F(BleConnectionManager, test_direct_connect_timeout) { EXPECT_CALL(*localAcceptlistMock, AcceptlistAdd(address1)) EXPECT_CALL(*localAcceptlistMock, AcceptlistAdd(address1, true)) .WillOnce(Return(true)); EXPECT_CALL(*AlarmMock::Get(), AlarmNew(_)).Times(1); alarm_callback_t alarm_callback = nullptr; Loading Loading @@ -223,7 +228,7 @@ TEST_F(BleConnectionManager, test_direct_connect_timeout) { /** Verify that we properly handle successfull direct connection */ TEST_F(BleConnectionManager, test_direct_connection_success) { EXPECT_CALL(*localAcceptlistMock, AcceptlistAdd(address1)) EXPECT_CALL(*localAcceptlistMock, AcceptlistAdd(address1, true)) .WillOnce(Return(true)); EXPECT_CALL(*AlarmMock::Get(), AlarmNew(_)).Times(1); EXPECT_CALL(*AlarmMock::Get(), AlarmSetOnMloop(_, _, _, _)).Times(1); Loading @@ -249,7 +254,7 @@ TEST_F(BleConnectionManager, test_app_unregister) { * - unregistration of Client2 should trigger address2 removal */ EXPECT_CALL(*localAcceptlistMock, AcceptlistAdd(address1)) EXPECT_CALL(*localAcceptlistMock, AcceptlistAdd(address1, true)) .WillOnce(Return(true)); EXPECT_CALL(*localAcceptlistMock, AcceptlistAdd(address2)) .WillOnce(Return(true)); Loading @@ -268,7 +273,7 @@ TEST_F(BleConnectionManager, test_app_unregister) { /** Verify adding device to both direct connection and background connection. */ TEST_F(BleConnectionManager, test_direct_and_background_connect) { EXPECT_CALL(*localAcceptlistMock, AcceptlistAdd(address1)) EXPECT_CALL(*localAcceptlistMock, AcceptlistAdd(address1, true)) .WillOnce(Return(true)); EXPECT_CALL(*localAcceptlistMock, AcceptlistRemove(_)).Times(0); EXPECT_CALL(*AlarmMock::Get(), AlarmNew(_)).Times(1); Loading system/test/mock/mock_stack_btm_ble_bgconn.cc +6 −0 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ struct BTM_BackgroundConnectAddressKnown BTM_BackgroundConnectAddressKnown; struct BTM_SetLeConnectionModeToFast BTM_SetLeConnectionModeToFast; struct BTM_SetLeConnectionModeToSlow BTM_SetLeConnectionModeToSlow; struct BTM_AcceptlistAdd BTM_AcceptlistAdd; struct BTM_AcceptlistAddDirect BTM_AcceptlistAddDirect; struct BTM_AcceptlistRemove BTM_AcceptlistRemove; struct BTM_AcceptlistClear BTM_AcceptlistClear; Loading Loading @@ -96,6 +97,11 @@ bool BTM_AcceptlistAdd(const RawAddress& address) { inc_func_call_count(__func__); return test::mock::stack_btm_ble_bgconn::BTM_AcceptlistAdd(address); } bool BTM_AcceptlistAdd(const RawAddress& address, bool is_direct) { inc_func_call_count(__func__); return test::mock::stack_btm_ble_bgconn::BTM_AcceptlistAddDirect(address, is_direct); } void BTM_AcceptlistRemove(const RawAddress& address) { inc_func_call_count(__func__); test::mock::stack_btm_ble_bgconn::BTM_AcceptlistRemove(address); Loading Loading
system/stack/btm/btm_ble_bgconn.cc +8 −2 Original line number Diff line number Diff line Loading @@ -173,6 +173,13 @@ bool BTM_BackgroundConnectAddressKnown(const RawAddress& address) { /** Adds the device into acceptlist. Returns false if acceptlist is full and * device can't be added, true otherwise. */ bool BTM_AcceptlistAdd(const RawAddress& address) { return BTM_AcceptlistAdd(address, false); } /** Adds the device into acceptlist and indicates whether to using direct * connect parameters. Returns false if acceptlist is full and device can't * be added, true otherwise. */ bool BTM_AcceptlistAdd(const RawAddress& address, bool is_direct) { if (!controller_get_interface()->supports_ble()) { LOG_WARN("Controller does not support Le"); return false; Loading @@ -181,8 +188,7 @@ bool BTM_AcceptlistAdd(const RawAddress& address) { tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(address); return bluetooth::shim::ACL_AcceptLeConnectionFrom( convert_to_address_with_type(address, p_dev_rec), /* is_direct */ false); convert_to_address_with_type(address, p_dev_rec), is_direct); } /** Removes the device from acceptlist */ Loading
system/stack/btm/btm_ble_bgconn.h +5 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,11 @@ * device can't be added, true otherwise. */ extern bool BTM_AcceptlistAdd(const RawAddress& address); /** Adds the device into acceptlist and indicates whether to using direct * connect parameters. Returns false if acceptlist is full and device can't * be added, true otherwise. */ extern bool BTM_AcceptlistAdd(const RawAddress& address, bool is_direct); /** Removes the device from acceptlist */ extern void BTM_AcceptlistRemove(const RawAddress& address); Loading
system/stack/gatt/connection_manager.cc +2 −2 Original line number Diff line number Diff line Loading @@ -464,7 +464,7 @@ void wl_direct_connect_timeout_cb(uint8_t app_id, const RawAddress& address) { direct_connect_remove(app_id, address); } /** Add a device to the direcgt connection list. Returns true if device /** Add a device to the direct connection list. Returns true if device * added to the list, false otherwise */ bool direct_connect_add(uint8_t app_id, const RawAddress& address) { LOG_DEBUG("app_id=%d, address=%s", static_cast<int>(app_id), Loading Loading @@ -492,7 +492,7 @@ bool direct_connect_add(uint8_t app_id, const RawAddress& address) { } if (!in_acceptlist) { if (!BTM_AcceptlistAdd(address)) { if (!BTM_AcceptlistAdd(address, true)) { // if we can't add to acceptlist, turn parameters back to slow. LOG_WARN("Unable to add le device to acceptlist"); return false; Loading
system/stack/test/gatt_connection_manager_test.cc +10 −5 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ namespace { class AcceptlistMock { public: MOCK_METHOD1(AcceptlistAdd, bool(const RawAddress&)); MOCK_METHOD2(AcceptlistAdd, bool(const RawAddress&, bool is_direct)); MOCK_METHOD1(AcceptlistRemove, void(const RawAddress&)); MOCK_METHOD0(AcceptlistClear, void()); MOCK_METHOD2(OnConnectionTimedOut, void(uint8_t, const RawAddress&)); Loading @@ -57,6 +58,10 @@ bool BTM_AcceptlistAdd(const RawAddress& address) { return localAcceptlistMock->AcceptlistAdd(address); } bool BTM_AcceptlistAdd(const RawAddress& address, bool is_direct) { return localAcceptlistMock->AcceptlistAdd(address, is_direct); } void BTM_AcceptlistRemove(const RawAddress& address) { return localAcceptlistMock->AcceptlistRemove(address); } Loading Loading @@ -166,7 +171,7 @@ TEST_F(BleConnectionManager, test_background_connection_multiple_clients) { TEST_F(BleConnectionManager, test_direct_connection_client) { // Direct connect attempt: use faster scan parameters, add to acceptlist, // start 30 timeout EXPECT_CALL(*localAcceptlistMock, AcceptlistAdd(address1)) EXPECT_CALL(*localAcceptlistMock, AcceptlistAdd(address1, true)) .WillOnce(Return(true)); EXPECT_CALL(*localAcceptlistMock, AcceptlistRemove(_)).Times(0); EXPECT_CALL(*AlarmMock::Get(), AlarmNew(_)).Times(1); Loading Loading @@ -195,7 +200,7 @@ TEST_F(BleConnectionManager, test_direct_connection_client) { /** Verify direct connection timeout does remove device from acceptlist, and * lower the connection scan parameters */ TEST_F(BleConnectionManager, test_direct_connect_timeout) { EXPECT_CALL(*localAcceptlistMock, AcceptlistAdd(address1)) EXPECT_CALL(*localAcceptlistMock, AcceptlistAdd(address1, true)) .WillOnce(Return(true)); EXPECT_CALL(*AlarmMock::Get(), AlarmNew(_)).Times(1); alarm_callback_t alarm_callback = nullptr; Loading Loading @@ -223,7 +228,7 @@ TEST_F(BleConnectionManager, test_direct_connect_timeout) { /** Verify that we properly handle successfull direct connection */ TEST_F(BleConnectionManager, test_direct_connection_success) { EXPECT_CALL(*localAcceptlistMock, AcceptlistAdd(address1)) EXPECT_CALL(*localAcceptlistMock, AcceptlistAdd(address1, true)) .WillOnce(Return(true)); EXPECT_CALL(*AlarmMock::Get(), AlarmNew(_)).Times(1); EXPECT_CALL(*AlarmMock::Get(), AlarmSetOnMloop(_, _, _, _)).Times(1); Loading @@ -249,7 +254,7 @@ TEST_F(BleConnectionManager, test_app_unregister) { * - unregistration of Client2 should trigger address2 removal */ EXPECT_CALL(*localAcceptlistMock, AcceptlistAdd(address1)) EXPECT_CALL(*localAcceptlistMock, AcceptlistAdd(address1, true)) .WillOnce(Return(true)); EXPECT_CALL(*localAcceptlistMock, AcceptlistAdd(address2)) .WillOnce(Return(true)); Loading @@ -268,7 +273,7 @@ TEST_F(BleConnectionManager, test_app_unregister) { /** Verify adding device to both direct connection and background connection. */ TEST_F(BleConnectionManager, test_direct_and_background_connect) { EXPECT_CALL(*localAcceptlistMock, AcceptlistAdd(address1)) EXPECT_CALL(*localAcceptlistMock, AcceptlistAdd(address1, true)) .WillOnce(Return(true)); EXPECT_CALL(*localAcceptlistMock, AcceptlistRemove(_)).Times(0); EXPECT_CALL(*AlarmMock::Get(), AlarmNew(_)).Times(1); Loading
system/test/mock/mock_stack_btm_ble_bgconn.cc +6 −0 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ struct BTM_BackgroundConnectAddressKnown BTM_BackgroundConnectAddressKnown; struct BTM_SetLeConnectionModeToFast BTM_SetLeConnectionModeToFast; struct BTM_SetLeConnectionModeToSlow BTM_SetLeConnectionModeToSlow; struct BTM_AcceptlistAdd BTM_AcceptlistAdd; struct BTM_AcceptlistAddDirect BTM_AcceptlistAddDirect; struct BTM_AcceptlistRemove BTM_AcceptlistRemove; struct BTM_AcceptlistClear BTM_AcceptlistClear; Loading Loading @@ -96,6 +97,11 @@ bool BTM_AcceptlistAdd(const RawAddress& address) { inc_func_call_count(__func__); return test::mock::stack_btm_ble_bgconn::BTM_AcceptlistAdd(address); } bool BTM_AcceptlistAdd(const RawAddress& address, bool is_direct) { inc_func_call_count(__func__); return test::mock::stack_btm_ble_bgconn::BTM_AcceptlistAddDirect(address, is_direct); } void BTM_AcceptlistRemove(const RawAddress& address) { inc_func_call_count(__func__); test::mock::stack_btm_ble_bgconn::BTM_AcceptlistRemove(address); Loading