• 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/classic/dynamic_channel_manager.h"
21 #include "l2cap/classic/fixed_channel_manager.h"
22 #include "l2cap/classic/link_property_listener.h"
23 #include "l2cap/classic/link_security_interface.h"
24 #include "l2cap/classic/security_enforcement_interface.h"
25 #include "module.h"
26 
27 namespace bluetooth {
28 
29 namespace security {
30 class SecurityModule;
31 }
32 
33 namespace l2cap {
34 namespace classic {
35 
36 class L2capClassicModule : public bluetooth::Module {
37  public:
38   L2capClassicModule();
39   virtual ~L2capClassicModule();
40 
41   /**
42    * Get the api to the classic fixed channel l2cap module
43    */
44   virtual std::unique_ptr<FixedChannelManager> GetFixedChannelManager();
45 
46   /**
47    * Get the api to the classic dynamic channel l2cap module
48    */
49   virtual std::unique_ptr<DynamicChannelManager> GetDynamicChannelManager();
50 
51   static const ModuleFactory Factory;
52   /**
53    * Only for the classic security module to inject functionality to enforce security level for a connection. When
54    * classic security module is stopping, inject nullptr. Note: We expect this only to be called during stack startup.
55    * This is not synchronized.
56    */
57   virtual void InjectSecurityEnforcementInterface(SecurityEnforcementInterface* security_enforcement_interface);
58 
59   /**
60    * Get the interface for Security Module to access link function.
61    * Security Module needs to register the callback for ACL link connected and disconnected. When connected, either by
62    * incoming or by outgoing connection request, Security Module receives a LinkSecurityInterface proxy, which can be
63    * used to access some link functionlities.
64    */
65   virtual SecurityInterface* GetSecurityInterface(os::Handler* handler, LinkSecurityInterfaceListener* listener);
66 
67   friend security::SecurityModule;
68 
69   /**
70    * Set the link property listener.
71    * This is not synchronized.
72    */
73   virtual void SetLinkPropertyListener(os::Handler* handler, LinkPropertyListener* listener);
74 
75  protected:
76   void ListDependencies(ModuleList* list) override;
77 
78   void Start() override;
79 
80   void Stop() override;
81 
82   std::string ToString() const override;
83 
84   DumpsysDataFinisher GetDumpsysData(flatbuffers::FlatBufferBuilder* builder) const override;  // Module
85 
86  private:
87   struct impl;
88   std::unique_ptr<impl> pimpl_;
89 
90   DISALLOW_COPY_AND_ASSIGN(L2capClassicModule);
91 };
92 
93 }  // namespace classic
94 }  // namespace l2cap
95 }  // namespace bluetooth
96