Loading system/gd/l2cap/Android.bp +3 −0 Original line number Diff line number Diff line Loading @@ -3,6 +3,9 @@ filegroup { srcs: [ "fcs.cc", "l2cap_layer.cc", "classic_dynamic_channel.cc", "classic_dynamic_channel_manager.cc", "classic_dynamic_channel_service.cc", "classic_fixed_channel.cc", "classic_fixed_channel_manager.cc", "classic_fixed_channel_service.cc", Loading system/gd/l2cap/cid.h +1 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,7 @@ constexpr Cid kInvalidCid = 0; constexpr Cid kFirstFixedChannel = 1; constexpr Cid kLastFixedChannel = 63; constexpr Cid kFirstDynamicChannel = kLastFixedChannel + 1; constexpr Cid kLastDynamicChannel = (uint16_t)(0xffff + 1); constexpr Cid kLastDynamicChannel = (uint16_t)(0xffff); constexpr Cid kClassicSignallingCid = 1; constexpr Cid kConnectionlessCid = 2; Loading system/gd/l2cap/classic_dynamic_channel.cc 0 → 100644 +37 −0 Original line number Diff line number Diff line /* * Copyright 2019 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "l2cap/classic_dynamic_channel.h" #include "common/bind.h" namespace bluetooth { namespace l2cap { hci::Address ClassicDynamicChannel::GetDevice() const { return {}; } void ClassicDynamicChannel::RegisterOnCloseCallback(os::Handler* user_handler, ClassicDynamicChannel::OnCloseCallback on_close_callback) {} void ClassicDynamicChannel::Close() {} common::BidiQueueEnd<packet::BasePacketBuilder, packet::PacketView<packet::kLittleEndian>>* ClassicDynamicChannel::GetQueueUpEnd() const { return nullptr; } } // namespace l2cap } // namespace bluetooth No newline at end of file system/gd/l2cap/classic_dynamic_channel.h 0 → 100644 +79 −0 Original line number Diff line number Diff line /* * Copyright 2019 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include "common/bidi_queue.h" #include "common/callback.h" #include "hci/acl_manager.h" #include "os/handler.h" #include "packet/base_packet_builder.h" #include "packet/packet_view.h" namespace bluetooth { namespace l2cap { namespace internal { class ClassicDynamicChannelImpl; } // namespace internal /** * L2CAP Dynamic channel object. User needs to call Close() when user no longer wants to use it. Otherwise the link * won't be disconnected. */ class ClassicDynamicChannel { public: // Should only be constructed by modules that have access to ClassicLinkManager ClassicDynamicChannel(std::shared_ptr<internal::ClassicDynamicChannelImpl> impl, os::Handler* l2cap_handler) : impl_(std::move(impl)), l2cap_handler_(l2cap_handler) { ASSERT(impl_ != nullptr); ASSERT(l2cap_handler_ != nullptr); } hci::Address GetDevice() const; /** * Register close callback. If close callback is registered, when a channel is closed, the channel's resource will * only be freed after on_close callback is invoked. Otherwise, if no on_close callback is registered, the channel's * resource will be freed immediately after closing. * * @param user_handler The handler used to invoke the callback on * @param on_close_callback The callback invoked upon channel closing. */ using OnCloseCallback = common::OnceCallback<void(hci::ErrorCode)>; void RegisterOnCloseCallback(os::Handler* user_handler, OnCloseCallback on_close_callback); /** * Indicate that this Dynamic Channel should be closed. OnCloseCallback will be invoked when channel close is done. * L2cay layer may terminate this ACL connection to free the resource after channel is closed. */ void Close(); /** * This method will retrieve the data channel queue to send and receive packets. * * {@see BidiQueueEnd} * * @return The upper end of a bi-directional queue. */ common::BidiQueueEnd<packet::BasePacketBuilder, packet::PacketView<packet::kLittleEndian>>* GetQueueUpEnd() const; private: std::shared_ptr<internal::ClassicDynamicChannelImpl> impl_; os::Handler* l2cap_handler_; }; } // namespace l2cap } // namespace bluetooth system/gd/l2cap/classic_dynamic_channel_manager.cc 0 → 100644 +37 −0 Original line number Diff line number Diff line /* * Copyright 2019 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "l2cap/classic_dynamic_channel_manager.h" #include "l2cap/internal/classic_link_manager.h" namespace bluetooth { namespace l2cap { bool ClassicDynamicChannelManager::ConnectChannel(hci::Address device, Psm psm, OnConnectionOpenCallback on_connection_open, OnConnectionFailureCallback on_fail_callback, os::Handler* handler) { // TODO impl me when there is no link, and when there is link return false; } bool ClassicDynamicChannelManager::RegisterService(Psm psm, const SecurityPolicy& security_policy, OnRegistrationCompleteCallback on_registration_complete, OnConnectionOpenCallback on_connection_open, os::Handler* handler) { return false; } } // namespace l2cap } // namespace bluetooth Loading
system/gd/l2cap/Android.bp +3 −0 Original line number Diff line number Diff line Loading @@ -3,6 +3,9 @@ filegroup { srcs: [ "fcs.cc", "l2cap_layer.cc", "classic_dynamic_channel.cc", "classic_dynamic_channel_manager.cc", "classic_dynamic_channel_service.cc", "classic_fixed_channel.cc", "classic_fixed_channel_manager.cc", "classic_fixed_channel_service.cc", Loading
system/gd/l2cap/cid.h +1 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,7 @@ constexpr Cid kInvalidCid = 0; constexpr Cid kFirstFixedChannel = 1; constexpr Cid kLastFixedChannel = 63; constexpr Cid kFirstDynamicChannel = kLastFixedChannel + 1; constexpr Cid kLastDynamicChannel = (uint16_t)(0xffff + 1); constexpr Cid kLastDynamicChannel = (uint16_t)(0xffff); constexpr Cid kClassicSignallingCid = 1; constexpr Cid kConnectionlessCid = 2; Loading
system/gd/l2cap/classic_dynamic_channel.cc 0 → 100644 +37 −0 Original line number Diff line number Diff line /* * Copyright 2019 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "l2cap/classic_dynamic_channel.h" #include "common/bind.h" namespace bluetooth { namespace l2cap { hci::Address ClassicDynamicChannel::GetDevice() const { return {}; } void ClassicDynamicChannel::RegisterOnCloseCallback(os::Handler* user_handler, ClassicDynamicChannel::OnCloseCallback on_close_callback) {} void ClassicDynamicChannel::Close() {} common::BidiQueueEnd<packet::BasePacketBuilder, packet::PacketView<packet::kLittleEndian>>* ClassicDynamicChannel::GetQueueUpEnd() const { return nullptr; } } // namespace l2cap } // namespace bluetooth No newline at end of file
system/gd/l2cap/classic_dynamic_channel.h 0 → 100644 +79 −0 Original line number Diff line number Diff line /* * Copyright 2019 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include "common/bidi_queue.h" #include "common/callback.h" #include "hci/acl_manager.h" #include "os/handler.h" #include "packet/base_packet_builder.h" #include "packet/packet_view.h" namespace bluetooth { namespace l2cap { namespace internal { class ClassicDynamicChannelImpl; } // namespace internal /** * L2CAP Dynamic channel object. User needs to call Close() when user no longer wants to use it. Otherwise the link * won't be disconnected. */ class ClassicDynamicChannel { public: // Should only be constructed by modules that have access to ClassicLinkManager ClassicDynamicChannel(std::shared_ptr<internal::ClassicDynamicChannelImpl> impl, os::Handler* l2cap_handler) : impl_(std::move(impl)), l2cap_handler_(l2cap_handler) { ASSERT(impl_ != nullptr); ASSERT(l2cap_handler_ != nullptr); } hci::Address GetDevice() const; /** * Register close callback. If close callback is registered, when a channel is closed, the channel's resource will * only be freed after on_close callback is invoked. Otherwise, if no on_close callback is registered, the channel's * resource will be freed immediately after closing. * * @param user_handler The handler used to invoke the callback on * @param on_close_callback The callback invoked upon channel closing. */ using OnCloseCallback = common::OnceCallback<void(hci::ErrorCode)>; void RegisterOnCloseCallback(os::Handler* user_handler, OnCloseCallback on_close_callback); /** * Indicate that this Dynamic Channel should be closed. OnCloseCallback will be invoked when channel close is done. * L2cay layer may terminate this ACL connection to free the resource after channel is closed. */ void Close(); /** * This method will retrieve the data channel queue to send and receive packets. * * {@see BidiQueueEnd} * * @return The upper end of a bi-directional queue. */ common::BidiQueueEnd<packet::BasePacketBuilder, packet::PacketView<packet::kLittleEndian>>* GetQueueUpEnd() const; private: std::shared_ptr<internal::ClassicDynamicChannelImpl> impl_; os::Handler* l2cap_handler_; }; } // namespace l2cap } // namespace bluetooth
system/gd/l2cap/classic_dynamic_channel_manager.cc 0 → 100644 +37 −0 Original line number Diff line number Diff line /* * Copyright 2019 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "l2cap/classic_dynamic_channel_manager.h" #include "l2cap/internal/classic_link_manager.h" namespace bluetooth { namespace l2cap { bool ClassicDynamicChannelManager::ConnectChannel(hci::Address device, Psm psm, OnConnectionOpenCallback on_connection_open, OnConnectionFailureCallback on_fail_callback, os::Handler* handler) { // TODO impl me when there is no link, and when there is link return false; } bool ClassicDynamicChannelManager::RegisterService(Psm psm, const SecurityPolicy& security_policy, OnRegistrationCompleteCallback on_registration_complete, OnConnectionOpenCallback on_connection_open, os::Handler* handler) { return false; } } // namespace l2cap } // namespace bluetooth