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/classic/fixed_channel_service.h" 23 #include "l2cap/classic/internal/fixed_channel_service_impl.h" 24 #include "os/handler.h" 25 26 namespace bluetooth { 27 namespace l2cap { 28 namespace classic { 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 virtual uint64_t GetSupportedFixedChannelMask(); 45 46 private: 47 os::Handler* l2cap_layer_handler_ = nullptr; 48 std::unordered_map<Cid, FixedChannelServiceImpl> service_map_; 49 }; 50 } // namespace internal 51 } // namespace classic 52 } // namespace l2cap 53 } // namespace bluetooth 54