/* * Copyright 2019 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include #include "l2cap/classic/dynamic_channel_service.h" #include "l2cap/classic/internal/dynamic_channel_service_impl.h" #include "l2cap/classic/security_enforcement_interface.h" #include "l2cap/psm.h" #include "os/handler.h" #include "os/log.h" namespace bluetooth { namespace l2cap { namespace classic { namespace internal { class DynamicChannelServiceManagerImpl { public: explicit DynamicChannelServiceManagerImpl(os::Handler* l2cap_layer_handler) : l2cap_layer_handler_(l2cap_layer_handler) {} virtual ~DynamicChannelServiceManagerImpl() = default; // // All APIs must be invoked in L2CAP layer handler // virtual void Register(Psm psm, DynamicChannelServiceImpl::PendingRegistration pending_registration); virtual void Unregister(Psm psm, DynamicChannelService::OnUnregisteredCallback callback); virtual bool IsServiceRegistered(Psm psm) const; virtual DynamicChannelServiceImpl* GetService(Psm psm); virtual std::vector> GetRegisteredServices(); // Implementation is set by SecurityManager through L2capModule void SetSecurityEnforcementInterface(SecurityEnforcementInterface* impl) { security_enforcement_interface_ = impl; } virtual SecurityEnforcementInterface* GetSecurityEnforcementInterface() { return security_enforcement_interface_; } private: os::Handler* l2cap_layer_handler_ = nullptr; std::unordered_map service_map_; SecurityEnforcementInterface* security_enforcement_interface_ = nullptr; }; } // namespace internal } // namespace classic } // namespace l2cap } // namespace bluetooth