From: Hansong Zhang Date: Wed, 30 Dec 2020 22:54:32 +0000 (-0800) Subject: LE L2cap shim: Implement fixed channel timeout X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=29b4d12753f469806d47ea6ba505cae0595c398a;p=android-x86%2Fsystem-bt.git LE L2cap shim: Implement fixed channel timeout Implement timeout settings with Fixed channel acquire/release. So far we only have two timeout options: no timeout, and disconnect immediately, which we can use existing methods to implement. Test: CtsVerifier Tag: #gd-refactor Bug: 141555841 Change-Id: If262e2773575b5c3c99a7286d66ca5f6a7fe7e58 --- diff --git a/main/shim/l2c_api.cc b/main/shim/l2c_api.cc index d49c5269f..01aa57684 100644 --- a/main/shim/l2c_api.cc +++ b/main/shim/l2c_api.cc @@ -637,8 +637,18 @@ bool L2CA_ConnectCreditBasedRsp(const RawAddress& bd_addr, uint8_t id, */ bool L2CA_SetIdleTimeoutByBdAddr(const RawAddress& bd_addr, uint16_t timeout, tBT_TRANSPORT transport) { - LOG_INFO("UNIMPLEMENTED %s", __func__); - return false; + if (transport == BT_TRANSPORT_BR_EDR) { + LOG_INFO("UNIMPLEMENTED %s", __func__); + return false; + } + constexpr int GATT_LINK_IDLE_TIMEOUT_WHEN_NO_APP = 1; + if (timeout == 0 || timeout == GATT_LINK_IDLE_TIMEOUT_WHEN_NO_APP) { + bluetooth::shim::L2CA_RemoveFixedChnl(kLeAttributeCid, bd_addr); + return true; + } else { + LOG_INFO("UNIMPLEMENTED %s", __func__); + return false; + } } bool L2CA_SetAclPriority(const RawAddress& bd_addr, tL2CAP_PRIORITY priority) { @@ -845,8 +855,16 @@ bool L2CA_SetTxPriority(uint16_t cid, tL2CAP_CHNL_PRIORITY priority) { bool L2CA_SetFixedChannelTout(const RawAddress& rem_bda, uint16_t fixed_cid, uint16_t idle_tout) { - LOG_INFO("UNIMPLEMENTED %s", __func__); - return false; + if (fixed_cid != kLeAttributeCid) { + LOG_INFO("UNIMPLEMENTED %s", __func__); + return false; + } + if (idle_tout == 0xffff) { + bluetooth::shim::L2CA_ConnectFixedChnl(kLeAttributeCid, rem_bda); + } else { + bluetooth::shim::L2CA_RemoveFixedChnl(kLeAttributeCid, rem_bda); + } + return true; } bool L2CA_SetChnlFlushability(uint16_t cid, bool is_flushable) {