Loading system/stack/gatt/connection_manager.cc +2 −0 Original line number Diff line number Diff line Loading @@ -183,6 +183,8 @@ void reset(bool after_reset) { } void wl_direct_connect_timeout_cb(uint8_t app_id, const RawAddress& address) { on_connection_timed_out(app_id, address); // TODO: this would free the timer, from within the timer callback, which is // bad. direct_connect_remove(app_id, address); Loading system/stack/gatt/connection_manager.h +5 −0 Original line number Diff line number Diff line Loading @@ -53,4 +53,9 @@ extern bool direct_connect_add(tAPP_ID app_id, const RawAddress& address); extern bool direct_connect_remove(tAPP_ID app_id, const RawAddress& address); extern void dump(int fd); /* This callback will be executed when direct connect attempt fails due to * timeout. It must be implemented by users of connection_manager */ extern void on_connection_timed_out(uint8_t app_id, const RawAddress& address); } // namespace connection_manager system/stack/gatt/gatt_main.cc +6 −0 Original line number Diff line number Diff line Loading @@ -383,6 +383,12 @@ bool gatt_act_connect(tGATT_REG* p_reg, const RawAddress& bd_addr, return true; } namespace connection_manager { void on_connection_timed_out(uint8_t app_id, const RawAddress& address) { gatt_le_connect_cback(L2CAP_ATT_CID, address, false, 0xff, BT_TRANSPORT_LE); } } // namespace connection_manager /** This callback function is called by L2CAP to indicate that the ATT fixed * channel for LE is connected (conn = true)/disconnected (conn = false). */ Loading system/stack/test/gatt_connection_manager_test.cc +6 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ class WhiteListMock { MOCK_METHOD0(WhiteListClear, void()); MOCK_METHOD0(SetLeConnectionModeToFast, bool()); MOCK_METHOD0(SetLeConnectionModeToSlow, void()); MOCK_METHOD2(OnConnectionTimedOut, void(uint8_t, const RawAddress&)); }; std::unique_ptr<WhiteListMock> localWhiteListMock; Loading Loading @@ -71,6 +72,10 @@ class BleConnectionManager : public testing::Test { } }; void on_connection_timed_out(uint8_t app_id, const RawAddress& address) { localWhiteListMock->OnConnectionTimedOut(app_id, address); } /** Verify that app can add a device to white list, it is returned as interested * app, and then can remove the device later. */ TEST_F(BleConnectionManager, test_background_connection_add_remove) { Loading Loading @@ -183,6 +188,7 @@ TEST_F(BleConnectionManager, test_direct_connect_timeout) { EXPECT_CALL(*localWhiteListMock, SetLeConnectionModeToSlow()).Times(1); EXPECT_CALL(*localWhiteListMock, WhiteListRemove(_)).Times(1); EXPECT_CALL(*localWhiteListMock, OnConnectionTimedOut(CLIENT1, address1)).Times(1); EXPECT_CALL(*AlarmMock::Get(), AlarmFree(_)).Times(1); // simulate timeout seconds passed, alarm executing Loading Loading
system/stack/gatt/connection_manager.cc +2 −0 Original line number Diff line number Diff line Loading @@ -183,6 +183,8 @@ void reset(bool after_reset) { } void wl_direct_connect_timeout_cb(uint8_t app_id, const RawAddress& address) { on_connection_timed_out(app_id, address); // TODO: this would free the timer, from within the timer callback, which is // bad. direct_connect_remove(app_id, address); Loading
system/stack/gatt/connection_manager.h +5 −0 Original line number Diff line number Diff line Loading @@ -53,4 +53,9 @@ extern bool direct_connect_add(tAPP_ID app_id, const RawAddress& address); extern bool direct_connect_remove(tAPP_ID app_id, const RawAddress& address); extern void dump(int fd); /* This callback will be executed when direct connect attempt fails due to * timeout. It must be implemented by users of connection_manager */ extern void on_connection_timed_out(uint8_t app_id, const RawAddress& address); } // namespace connection_manager
system/stack/gatt/gatt_main.cc +6 −0 Original line number Diff line number Diff line Loading @@ -383,6 +383,12 @@ bool gatt_act_connect(tGATT_REG* p_reg, const RawAddress& bd_addr, return true; } namespace connection_manager { void on_connection_timed_out(uint8_t app_id, const RawAddress& address) { gatt_le_connect_cback(L2CAP_ATT_CID, address, false, 0xff, BT_TRANSPORT_LE); } } // namespace connection_manager /** This callback function is called by L2CAP to indicate that the ATT fixed * channel for LE is connected (conn = true)/disconnected (conn = false). */ Loading
system/stack/test/gatt_connection_manager_test.cc +6 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ class WhiteListMock { MOCK_METHOD0(WhiteListClear, void()); MOCK_METHOD0(SetLeConnectionModeToFast, bool()); MOCK_METHOD0(SetLeConnectionModeToSlow, void()); MOCK_METHOD2(OnConnectionTimedOut, void(uint8_t, const RawAddress&)); }; std::unique_ptr<WhiteListMock> localWhiteListMock; Loading Loading @@ -71,6 +72,10 @@ class BleConnectionManager : public testing::Test { } }; void on_connection_timed_out(uint8_t app_id, const RawAddress& address) { localWhiteListMock->OnConnectionTimedOut(app_id, address); } /** Verify that app can add a device to white list, it is returned as interested * app, and then can remove the device later. */ TEST_F(BleConnectionManager, test_background_connection_add_remove) { Loading Loading @@ -183,6 +188,7 @@ TEST_F(BleConnectionManager, test_direct_connect_timeout) { EXPECT_CALL(*localWhiteListMock, SetLeConnectionModeToSlow()).Times(1); EXPECT_CALL(*localWhiteListMock, WhiteListRemove(_)).Times(1); EXPECT_CALL(*localWhiteListMock, OnConnectionTimedOut(CLIENT1, address1)).Times(1); EXPECT_CALL(*AlarmMock::Get(), AlarmFree(_)).Times(1); // simulate timeout seconds passed, alarm executing Loading