• 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   L2capLeModule(const L2capLeModule&) = delete;
43   L2capLeModule& operator=(const L2capLeModule&) = delete;
44 
45   virtual ~L2capLeModule();
46 
47   /**
48    * Get the api to the LE fixed channel l2cap module
49    */
50   virtual std::unique_ptr<FixedChannelManager> GetFixedChannelManager();
51 
52   /**
53    * Get the api to the LE dynamic channel l2cap module
54    */
55   virtual std::unique_ptr<DynamicChannelManager> GetDynamicChannelManager();
56 
57   static const ModuleFactory Factory;
58 
59  protected:
60   void ListDependencies(ModuleList* list) const override;
61 
62   void Start() override;
63 
64   void Stop() override;
65 
66   std::string ToString() const override;
67 
68  private:
69   struct impl;
70   std::unique_ptr<impl> pimpl_;
71 
72   friend security::SecurityModule;
73   friend void bluetooth::shim::L2CA_UseLegacySecurityModule();
74 
75   /**
76    * Only for the LE security module to inject functionality to enforce security level for a connection. When LE
77    * security module is stopping, inject nullptr. Note: We expect this only to be called during stack startup. This is
78    * not synchronized.
79    */
80   virtual void InjectSecurityEnforcementInterface(SecurityEnforcementInterface* security_enforcement_interface);
81 
82   /**
83    * Set the link property listener.
84    * This is not synchronized.
85    */
86   virtual void SetLinkPropertyListener(os::Handler* handler, LinkPropertyListener* listener);
87 };
88 
89 }  // namespace le
90 }  // namespace l2cap
91 }  // namespace bluetooth
92