• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <atomic>
20 #include <memory>
21 
22 #include "hci/acl_connection_interface.h"
23 #include "hci/acl_manager/acl_connection.h"
24 #include "hci/acl_manager/connection_management_callbacks.h"
25 #include "hci/hci_packets.h"
26 
27 namespace bluetooth {
28 namespace hci {
29 namespace acl_manager {
30 
31 class ClassicAclConnection : public AclConnection {
32  public:
33   ClassicAclConnection();
34   ClassicAclConnection(std::shared_ptr<Queue> queue, 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 {
42     return address_;
43   }
44 
45   virtual void RegisterCallbacks(ConnectionManagementCallbacks* callbacks, os::Handler* handler);
46   virtual bool Disconnect(DisconnectReason reason);
47   virtual bool ChangeConnectionPacketType(uint16_t packet_type);
48   virtual bool AuthenticationRequested();
49   virtual bool SetConnectionEncryption(Enable enable);
50   virtual bool ChangeConnectionLinkKey();
51   virtual bool ReadClockOffset();
52   virtual bool HoldMode(uint16_t max_interval, uint16_t min_interval);
53   virtual bool SniffMode(uint16_t max_interval, uint16_t min_interval, uint16_t attempt, uint16_t timeout);
54   virtual bool ExitSniffMode();
55   virtual bool QosSetup(ServiceType service_type, uint32_t token_rate, uint32_t peak_bandwidth, uint32_t latency,
56                         uint32_t delay_variation);
57   virtual bool RoleDiscovery();
58   virtual bool ReadLinkPolicySettings();
59   virtual bool WriteLinkPolicySettings(uint16_t link_policy_settings);
60   virtual bool FlowSpecification(FlowDirection flow_direction, ServiceType service_type, uint32_t token_rate,
61                                  uint32_t token_bucket_size, 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(std::function<void(uint16_t)> invalidate_callbacks);
82 
83  private:
84   AclConnectionInterface* acl_connection_interface_;
85 
86  protected:
87   Address address_;
88 
89  private:
90   struct impl;
91   struct impl* pimpl_ = nullptr;
92 };
93 
94 }  // namespace acl_manager
95 }  // namespace hci
96 }  // namespace bluetooth
97