• 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 #pragma once
17 
18 #include <memory>
19 
20 #include "l2cap/le/dynamic_channel_manager.h"
21 #include "l2cap/le/fixed_channel_manager.h"
22 #include "l2cap/le/link_property_listener.h"
23 #include "l2cap/le/security_enforcement_interface.h"
24 #include "module.h"
25 
26 namespace bluetooth {
27 
28 namespace shim {
29 void L2CA_UseLegacySecurityModule();
30 }
31 
32 namespace security {
33 class SecurityModule;
34 }
35 
36 namespace l2cap {
37 namespace le {
38 
39 class L2capLeModule : public bluetooth::Module {
40  public:
41   L2capLeModule();
42   virtual ~L2capLeModule();
43 
44   /**
45    * Get the api to the LE fixed channel l2cap module
46    */
47   virtual std::unique_ptr<FixedChannelManager> GetFixedChannelManager();
48 
49   /**
50    * Get the api to the LE dynamic channel l2cap module
51    */
52   virtual std::unique_ptr<DynamicChannelManager> GetDynamicChannelManager();
53 
54   static const ModuleFactory Factory;
55 
56  protected:
57   void ListDependencies(ModuleList* list) override;
58 
59   void Start() override;
60 
61   void Stop() override;
62 
63   std::string ToString() const override;
64 
65  private:
66   struct impl;
67   std::unique_ptr<impl> pimpl_;
68 
69   friend security::SecurityModule;
70   friend void bluetooth::shim::L2CA_UseLegacySecurityModule();
71 
72   /**
73    * Only for the LE security module to inject functionality to enforce security level for a connection. When LE
74    * security module is stopping, inject nullptr. Note: We expect this only to be called during stack startup. This is
75    * not synchronized.
76    */
77   virtual void InjectSecurityEnforcementInterface(SecurityEnforcementInterface* security_enforcement_interface);
78 
79   /**
80    * Set the link property listener.
81    * This is not synchronized.
82    */
83   virtual void SetLinkPropertyListener(os::Handler* handler, LinkPropertyListener* listener);
84 
85   DISALLOW_COPY_AND_ASSIGN(L2capLeModule);
86 };
87 
88 }  // namespace le
89 }  // namespace l2cap
90 }  // namespace bluetooth
91