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 "l2cap/classic/dynamic_channel.h" 20 #include "l2cap/classic/dynamic_channel_configuration_option.h" 21 #include "l2cap/classic/dynamic_channel_manager.h" 22 #include "l2cap/classic/dynamic_channel_service.h" 23 #include "l2cap/classic/security_policy.h" 24 25 namespace bluetooth { 26 namespace l2cap { 27 namespace classic { 28 namespace internal { 29 class DynamicChannelServiceImpl { 30 public: 31 virtual ~DynamicChannelServiceImpl() = default; 32 33 struct PendingRegistration { 34 os::Handler* user_handler_ = nullptr; 35 classic::SecurityPolicy security_policy_; 36 DynamicChannelManager::OnRegistrationCompleteCallback on_registration_complete_callback_; 37 DynamicChannelManager::OnConnectionOpenCallback on_connection_open_callback_; 38 DynamicChannelConfigurationOption configuration_; 39 }; 40 NotifyChannelCreation(std::unique_ptr<DynamicChannel> channel)41 virtual void NotifyChannelCreation(std::unique_ptr<DynamicChannel> channel) { 42 on_connection_open_callback_(std::move(channel)); 43 } 44 GetConfigOption()45 virtual DynamicChannelConfigurationOption GetConfigOption() const { 46 return config_option_; 47 } 48 GetSecurityPolicy()49 virtual SecurityPolicy GetSecurityPolicy() const { 50 return security_policy_; 51 } 52 53 friend class DynamicChannelServiceManagerImpl; 54 55 protected: 56 // protected access for mocking DynamicChannelServiceImpl(classic::SecurityPolicy security_policy,DynamicChannelManager::OnConnectionOpenCallback on_connection_open_callback,DynamicChannelConfigurationOption config_option)57 DynamicChannelServiceImpl( 58 classic::SecurityPolicy security_policy, 59 DynamicChannelManager::OnConnectionOpenCallback on_connection_open_callback, 60 DynamicChannelConfigurationOption config_option) 61 : security_policy_(security_policy), 62 on_connection_open_callback_(std::move(on_connection_open_callback)), 63 config_option_(config_option) {} 64 65 private: 66 classic::SecurityPolicy security_policy_; 67 DynamicChannelManager::OnConnectionOpenCallback on_connection_open_callback_; 68 DynamicChannelConfigurationOption config_option_; 69 }; 70 71 } // namespace internal 72 } // namespace classic 73 } // namespace l2cap 74 } // namespace bluetooth 75