• 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 
17 #pragma once
18 
19 #include <unordered_map>
20 
21 #include "l2cap/cid.h"
22 #include "l2cap/le/fixed_channel_service.h"
23 #include "l2cap/le/internal/fixed_channel_service_impl.h"
24 #include "os/handler.h"
25 
26 namespace bluetooth {
27 namespace l2cap {
28 namespace le {
29 namespace internal {
30 
31 class FixedChannelServiceManagerImpl {
32  public:
FixedChannelServiceManagerImpl(os::Handler * l2cap_layer_handler)33   explicit FixedChannelServiceManagerImpl(os::Handler* l2cap_layer_handler)
34       : l2cap_layer_handler_(l2cap_layer_handler) {}
35   virtual ~FixedChannelServiceManagerImpl() = default;
36 
37   // All APIs must be invoked in L2CAP layer handler
38 
39   virtual void Register(Cid cid, FixedChannelServiceImpl::PendingRegistration pending_registration);
40   virtual void Unregister(Cid cid, FixedChannelService::OnUnregisteredCallback callback, os::Handler* handler);
41   virtual bool IsServiceRegistered(Cid cid) const;
42   virtual FixedChannelServiceImpl* GetService(Cid cid);
43   virtual std::vector<std::pair<Cid, FixedChannelServiceImpl*>> GetRegisteredServices();
44 
45  private:
46   os::Handler* l2cap_layer_handler_ = nullptr;
47   std::unordered_map<Cid, FixedChannelServiceImpl> service_map_;
48 };
49 }  // namespace internal
50 }  // namespace le
51 }  // namespace l2cap
52 }  // namespace bluetooth
53