• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #define LOG_TAG "l2cap2"
17 
18 #include <memory>
19 
20 #include "common/bidi_queue.h"
21 #include "hci/acl_manager.h"
22 #include "hci/address.h"
23 #include "hci/hci_layer.h"
24 #include "hci/hci_packets.h"
25 #include "l2cap/internal/parameter_provider.h"
26 #include "l2cap/le/internal/fixed_channel_service_manager_impl.h"
27 #include "l2cap/le/internal/link_manager.h"
28 #include "module.h"
29 #include "os/handler.h"
30 #include "os/log.h"
31 
32 #include "l2cap/le/l2cap_le_module.h"
33 
34 namespace bluetooth {
35 namespace l2cap {
36 namespace le {
37 
__anon236a12990102() 38 const ModuleFactory L2capLeModule::Factory = ModuleFactory([]() { return new L2capLeModule(); });
39 
40 struct L2capLeModule::impl {
implbluetooth::l2cap::le::L2capLeModule::impl41   impl(os::Handler* l2cap_handler, hci::AclManager* acl_manager)
42       : l2cap_handler_(l2cap_handler), acl_manager_(acl_manager) {}
43   os::Handler* l2cap_handler_;
44   hci::AclManager* acl_manager_;
45   l2cap::internal::ParameterProvider parameter_provider_;
46   internal::FixedChannelServiceManagerImpl fixed_channel_service_manager_impl_{l2cap_handler_};
47   internal::LinkManager link_manager_{l2cap_handler_, acl_manager_, &fixed_channel_service_manager_impl_,
48                                       &parameter_provider_};
49 };
50 
L2capLeModule()51 L2capLeModule::L2capLeModule() {}
~L2capLeModule()52 L2capLeModule::~L2capLeModule() {}
53 
ListDependencies(ModuleList * list)54 void L2capLeModule::ListDependencies(ModuleList* list) {
55   list->add<hci::AclManager>();
56 }
57 
Start()58 void L2capLeModule::Start() {
59   pimpl_ = std::make_unique<impl>(GetHandler(), GetDependency<hci::AclManager>());
60 }
61 
Stop()62 void L2capLeModule::Stop() {
63   pimpl_.reset();
64 }
65 
ToString() const66 std::string L2capLeModule::ToString() const {
67   return "L2cap Le Module";
68 }
69 
GetFixedChannelManager()70 std::unique_ptr<FixedChannelManager> L2capLeModule::GetFixedChannelManager() {
71   return std::unique_ptr<FixedChannelManager>(new FixedChannelManager(&pimpl_->fixed_channel_service_manager_impl_,
72                                                                       &pimpl_->link_manager_, pimpl_->l2cap_handler_));
73 }
74 
75 }  // namespace le
76 }  // namespace l2cap
77 }  // namespace bluetooth
78