1 /* 2 * Copyright 2020 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 <memory> 20 21 #include "hci/acl_connection_interface.h" 22 #include "hci/acl_manager/acl_connection.h" 23 #include "hci/acl_manager/connection_management_callbacks.h" 24 #include "hci/hci_packets.h" 25 26 namespace bluetooth { 27 namespace hci { 28 namespace acl_manager { 29 30 class ClassicAclConnection : public AclConnection { 31 public: 32 ClassicAclConnection(); 33 ClassicAclConnection(std::shared_ptr<Queue> queue, 34 AclConnectionInterface* acl_connection_interface, uint16_t handle, 35 Address address); 36 ClassicAclConnection(const ClassicAclConnection&) = delete; 37 ClassicAclConnection& operator=(const ClassicAclConnection&) = delete; 38 39 ~ClassicAclConnection(); 40 GetAddress()41 virtual Address GetAddress() const { return address_; } 42 43 virtual void RegisterCallbacks(ConnectionManagementCallbacks* callbacks, os::Handler* handler); 44 virtual bool Disconnect(DisconnectReason reason); 45 virtual bool ChangeConnectionPacketType(uint16_t packet_type); 46 virtual bool AuthenticationRequested(); 47 virtual bool SetConnectionEncryption(Enable enable); 48 virtual bool ChangeConnectionLinkKey(); 49 virtual bool ReadClockOffset(); 50 virtual bool HoldMode(uint16_t max_interval, uint16_t min_interval); 51 virtual bool SniffMode(uint16_t max_interval, uint16_t min_interval, uint16_t attempt, 52 uint16_t timeout); 53 virtual bool ExitSniffMode(); 54 virtual bool QosSetup(ServiceType service_type, uint32_t token_rate, uint32_t peak_bandwidth, 55 uint32_t latency, uint32_t delay_variation); 56 virtual bool RoleDiscovery(); 57 virtual bool ReadLinkPolicySettings(); 58 virtual bool WriteLinkPolicySettings(uint16_t link_policy_settings); 59 virtual bool FlowSpecification(FlowDirection flow_direction, ServiceType service_type, 60 uint32_t token_rate, uint32_t token_bucket_size, 61 uint32_t peak_bandwidth, uint32_t access_latency); 62 virtual bool SniffSubrating(uint16_t maximum_latency, uint16_t minimum_remote_timeout, 63 uint16_t minimum_local_timeout); 64 virtual bool Flush(); 65 virtual bool ReadAutomaticFlushTimeout(); 66 virtual bool WriteAutomaticFlushTimeout(uint16_t flush_timeout); 67 virtual bool ReadTransmitPowerLevel(TransmitPowerLevelType type); 68 virtual bool ReadLinkSupervisionTimeout(); 69 virtual bool WriteLinkSupervisionTimeout(uint16_t link_supervision_timeout); 70 virtual bool ReadFailedContactCounter(); 71 virtual bool ResetFailedContactCounter(); 72 virtual bool ReadLinkQuality(); 73 virtual bool ReadAfhChannelMap(); 74 virtual bool ReadRssi(); 75 virtual bool ReadClock(WhichClock which_clock); 76 virtual bool ReadRemoteVersionInformation() override; 77 virtual bool ReadRemoteSupportedFeatures(); 78 virtual bool ReadRemoteExtendedFeatures(uint8_t page_number); 79 80 // Called once before passing the connection to the client 81 virtual ConnectionManagementCallbacks* GetEventCallbacks( 82 std::function<void(uint16_t)> invalidate_callbacks); 83 84 private: 85 AclConnectionInterface* acl_connection_interface_; 86 bool is_disconnecting_ = false; 87 88 protected: 89 Address address_; 90 91 private: 92 struct impl; 93 struct impl* pimpl_ = nullptr; 94 }; 95 96 } // namespace acl_manager 97 } // namespace hci 98 } // namespace bluetooth 99