Loading system/gd/l2cap/Android.bp +8 −3 Original line number Diff line number Diff line Loading @@ -24,12 +24,16 @@ filegroup { "internal/receiver.cc", "internal/scheduler_fifo.cc", "internal/sender.cc", "le/internal/fixed_channel_impl.cc", "le/internal/fixed_channel_service_manager_impl.cc", "le/internal/link_manager.cc", "le/dynamic_channel_manager.cc", "le/dynamic_channel_service.cc", "le/fixed_channel.cc", "le/fixed_channel_manager.cc", "le/fixed_channel_service.cc", "le/internal/dynamic_channel_service_manager_impl.cc", "le/internal/fixed_channel_impl.cc", "le/internal/fixed_channel_service_manager_impl.cc", "le/internal/link.cc", "le/internal/link_manager.cc", "le/l2cap_le_module.cc", ], } Loading @@ -52,6 +56,7 @@ filegroup { "internal/scheduler_fifo_test.cc", "internal/sender_test.cc", "l2cap_packet_test.cc", "le/internal/dynamic_channel_service_manager_test.cc", "le/internal/fixed_channel_impl_test.cc", "le/internal/fixed_channel_service_manager_test.cc", "le/internal/link_manager_test.cc", Loading system/gd/l2cap/classic/internal/link.cc +2 −2 Original line number Diff line number Diff line Loading @@ -158,11 +158,11 @@ void Link::NotifyChannelFail(Cid cid) { } void Link::SetRemoteConnectionlessMtu(Mtu mtu) { remote_mtu_ = mtu; remote_connectionless_mtu_ = mtu; } Mtu Link::GetRemoteConnectionlessMtu() const { return remote_mtu_; return remote_connectionless_mtu_; } void Link::SetRemoteSupportsErtm(bool supported) { Loading system/gd/l2cap/classic/internal/link.h +3 −3 Original line number Diff line number Diff line Loading @@ -46,9 +46,9 @@ class Link : public l2cap::internal::ILink { DynamicChannelServiceManagerImpl* dynamic_service_manager, FixedChannelServiceManagerImpl* fixed_service_manager); virtual ~Link() = default; ~Link() override = default; virtual hci::AddressWithType GetDevice() { hci::AddressWithType GetDevice() override { return {acl_connection_->GetAddress(), acl_connection_->GetAddressType()}; } Loading Loading @@ -123,7 +123,7 @@ class Link : public l2cap::internal::ILink { ClassicSignallingManager signalling_manager_; std::unordered_map<Cid, PendingDynamicChannelConnection> local_cid_to_pending_dynamic_channel_connection_map_; os::Alarm link_idle_disconnect_alarm_{l2cap_handler_}; Mtu remote_mtu_ = kMinimumClassicMtu; Mtu remote_connectionless_mtu_ = kMinimumClassicMtu; bool remote_supports_ertm_ = false; bool remote_supports_fcs_ = false; DISALLOW_COPY_AND_ASSIGN(Link); Loading system/gd/l2cap/le/dynamic_channel_configuration_option.h 0 → 100644 +39 −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 "l2cap/mtu.h" namespace bluetooth { namespace l2cap { namespace le { /** * Configuration Option specified by L2CAP Channel user on a dynamic channel. L2CAP module will configure the channel * based on user provided option. */ struct DynamicChannelConfigurationOption { /** * Maximum SDU size that the L2CAP Channel user is able to receive or send. When the channel is created, the actual * MTU is the minimum of the suggested MTU between two devices. */ Mtu mtu = kDefaultClassicMtu; }; } // namespace le } // namespace l2cap } // namespace bluetooth system/gd/l2cap/le/dynamic_channel_manager.cc 0 → 100644 +63 −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/le/dynamic_channel_manager.h" #include "l2cap/le/internal/dynamic_channel_service_impl.h" #include "l2cap/le/internal/dynamic_channel_service_manager_impl.h" #include "l2cap/le/internal/link.h" #include "l2cap/le/internal/link_manager.h" namespace bluetooth { namespace l2cap { namespace le { bool DynamicChannelManager::ConnectChannel(hci::AddressWithType device, DynamicChannelConfigurationOption configuration_option, Psm psm, OnConnectionOpenCallback on_connection_open, OnConnectionFailureCallback on_fail_callback, os::Handler* handler) { internal::Link::PendingDynamicChannelConnection pending_dynamic_channel_connection{ .handler_ = handler, .on_open_callback_ = std::move(on_connection_open), .on_fail_callback_ = std::move(on_fail_callback), .configuration_ = configuration_option, }; l2cap_layer_handler_->Post(common::BindOnce(&internal::LinkManager::ConnectDynamicChannelServices, common::Unretained(link_manager_), device, std::move(pending_dynamic_channel_connection), psm)); return true; } bool DynamicChannelManager::RegisterService(Psm psm, DynamicChannelConfigurationOption configuration_option, const SecurityPolicy& security_policy, OnRegistrationCompleteCallback on_registration_complete, OnConnectionOpenCallback on_connection_open, os::Handler* handler) { internal::DynamicChannelServiceImpl::PendingRegistration pending_registration{ .user_handler_ = handler, .on_registration_complete_callback_ = std::move(on_registration_complete), .on_connection_open_callback_ = std::move(on_connection_open), .configuration_ = configuration_option, }; l2cap_layer_handler_->Post(common::BindOnce(&internal::DynamicChannelServiceManagerImpl::Register, common::Unretained(service_manager_), psm, std::move(pending_registration))); return true; } } // namespace le } // namespace l2cap } // namespace bluetooth Loading
system/gd/l2cap/Android.bp +8 −3 Original line number Diff line number Diff line Loading @@ -24,12 +24,16 @@ filegroup { "internal/receiver.cc", "internal/scheduler_fifo.cc", "internal/sender.cc", "le/internal/fixed_channel_impl.cc", "le/internal/fixed_channel_service_manager_impl.cc", "le/internal/link_manager.cc", "le/dynamic_channel_manager.cc", "le/dynamic_channel_service.cc", "le/fixed_channel.cc", "le/fixed_channel_manager.cc", "le/fixed_channel_service.cc", "le/internal/dynamic_channel_service_manager_impl.cc", "le/internal/fixed_channel_impl.cc", "le/internal/fixed_channel_service_manager_impl.cc", "le/internal/link.cc", "le/internal/link_manager.cc", "le/l2cap_le_module.cc", ], } Loading @@ -52,6 +56,7 @@ filegroup { "internal/scheduler_fifo_test.cc", "internal/sender_test.cc", "l2cap_packet_test.cc", "le/internal/dynamic_channel_service_manager_test.cc", "le/internal/fixed_channel_impl_test.cc", "le/internal/fixed_channel_service_manager_test.cc", "le/internal/link_manager_test.cc", Loading
system/gd/l2cap/classic/internal/link.cc +2 −2 Original line number Diff line number Diff line Loading @@ -158,11 +158,11 @@ void Link::NotifyChannelFail(Cid cid) { } void Link::SetRemoteConnectionlessMtu(Mtu mtu) { remote_mtu_ = mtu; remote_connectionless_mtu_ = mtu; } Mtu Link::GetRemoteConnectionlessMtu() const { return remote_mtu_; return remote_connectionless_mtu_; } void Link::SetRemoteSupportsErtm(bool supported) { Loading
system/gd/l2cap/classic/internal/link.h +3 −3 Original line number Diff line number Diff line Loading @@ -46,9 +46,9 @@ class Link : public l2cap::internal::ILink { DynamicChannelServiceManagerImpl* dynamic_service_manager, FixedChannelServiceManagerImpl* fixed_service_manager); virtual ~Link() = default; ~Link() override = default; virtual hci::AddressWithType GetDevice() { hci::AddressWithType GetDevice() override { return {acl_connection_->GetAddress(), acl_connection_->GetAddressType()}; } Loading Loading @@ -123,7 +123,7 @@ class Link : public l2cap::internal::ILink { ClassicSignallingManager signalling_manager_; std::unordered_map<Cid, PendingDynamicChannelConnection> local_cid_to_pending_dynamic_channel_connection_map_; os::Alarm link_idle_disconnect_alarm_{l2cap_handler_}; Mtu remote_mtu_ = kMinimumClassicMtu; Mtu remote_connectionless_mtu_ = kMinimumClassicMtu; bool remote_supports_ertm_ = false; bool remote_supports_fcs_ = false; DISALLOW_COPY_AND_ASSIGN(Link); Loading
system/gd/l2cap/le/dynamic_channel_configuration_option.h 0 → 100644 +39 −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 "l2cap/mtu.h" namespace bluetooth { namespace l2cap { namespace le { /** * Configuration Option specified by L2CAP Channel user on a dynamic channel. L2CAP module will configure the channel * based on user provided option. */ struct DynamicChannelConfigurationOption { /** * Maximum SDU size that the L2CAP Channel user is able to receive or send. When the channel is created, the actual * MTU is the minimum of the suggested MTU between two devices. */ Mtu mtu = kDefaultClassicMtu; }; } // namespace le } // namespace l2cap } // namespace bluetooth
system/gd/l2cap/le/dynamic_channel_manager.cc 0 → 100644 +63 −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/le/dynamic_channel_manager.h" #include "l2cap/le/internal/dynamic_channel_service_impl.h" #include "l2cap/le/internal/dynamic_channel_service_manager_impl.h" #include "l2cap/le/internal/link.h" #include "l2cap/le/internal/link_manager.h" namespace bluetooth { namespace l2cap { namespace le { bool DynamicChannelManager::ConnectChannel(hci::AddressWithType device, DynamicChannelConfigurationOption configuration_option, Psm psm, OnConnectionOpenCallback on_connection_open, OnConnectionFailureCallback on_fail_callback, os::Handler* handler) { internal::Link::PendingDynamicChannelConnection pending_dynamic_channel_connection{ .handler_ = handler, .on_open_callback_ = std::move(on_connection_open), .on_fail_callback_ = std::move(on_fail_callback), .configuration_ = configuration_option, }; l2cap_layer_handler_->Post(common::BindOnce(&internal::LinkManager::ConnectDynamicChannelServices, common::Unretained(link_manager_), device, std::move(pending_dynamic_channel_connection), psm)); return true; } bool DynamicChannelManager::RegisterService(Psm psm, DynamicChannelConfigurationOption configuration_option, const SecurityPolicy& security_policy, OnRegistrationCompleteCallback on_registration_complete, OnConnectionOpenCallback on_connection_open, os::Handler* handler) { internal::DynamicChannelServiceImpl::PendingRegistration pending_registration{ .user_handler_ = handler, .on_registration_complete_callback_ = std::move(on_registration_complete), .on_connection_open_callback_ = std::move(on_connection_open), .configuration_ = configuration_option, }; l2cap_layer_handler_->Post(common::BindOnce(&internal::DynamicChannelServiceManagerImpl::Register, common::Unretained(service_manager_), psm, std::move(pending_registration))); return true; } } // namespace le } // namespace l2cap } // namespace bluetooth