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