• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2018 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 "stack/include/avrc_api.h"
20 #include "stack/include/sdp_api.h"
21 
22 /**
23  * Wrapper classes for the API functions currently defined in "system/bt/stack".
24  * ConnectionHandler and AvrcpDevice both use this interface to manage AVRCP
25  * SDP, connections, and packets. We use these intermediate interfaces instead
26  * of calling the functions directly in order to make mocking and testing
27  * easier.
28  */
29 // TODO (apanicke): Update the api's in "system/bt/stack" so that no wrapper is
30 // required
31 class AvrcpInterface {
32  public:
33   virtual uint16_t AddRecord(uint16_t service_uuid, const char* p_service_name,
34                              const char* p_provider_name, uint16_t categories,
35                              uint32_t sdp_handle, bool browse_supported,
36                              uint16_t profile_version) = 0;
37 
38   virtual uint16_t FindService(uint16_t service_uuid, const RawAddress& bd_addr,
39                                tAVRC_SDP_DB_PARAMS* p_db,
40                                tAVRC_FIND_CBACK p_cback) = 0;
41 
42   virtual uint16_t Open(uint8_t* p_handle, tAVRC_CONN_CB* p_ccb,
43                         const RawAddress& bd_addr) = 0;
44 
45   virtual uint16_t OpenBrowse(uint8_t handle, uint8_t conn_role) = 0;
46 
47   virtual uint16_t GetPeerMtu(uint8_t handle) = 0;
48 
49   virtual uint16_t GetBrowseMtu(uint8_t handle) = 0;
50 
51   virtual uint16_t Close(uint8_t handle) = 0;
52 
53   virtual uint16_t CloseBrowse(uint8_t handle) = 0;
54 
55   virtual uint16_t MsgReq(uint8_t handle, uint8_t label, uint8_t ctype,
56                           BT_HDR* p_pkt) = 0;
57 
58   virtual ~AvrcpInterface() = default;
59 };
60 
61 class SdpInterface {
62  public:
63   virtual bool InitDiscoveryDb(tSDP_DISCOVERY_DB* a, uint32_t b, uint16_t c,
64                                const bluetooth::Uuid* d, uint16_t e,
65                                uint16_t* f) = 0;
66 
67   virtual bool ServiceSearchAttributeRequest(const RawAddress& a,
68                                              tSDP_DISCOVERY_DB* b,
69                                              tSDP_DISC_CMPL_CB* c) = 0;
70 
71   virtual tSDP_DISC_REC* FindServiceInDb(tSDP_DISCOVERY_DB* a, uint16_t b,
72                                          t_sdp_disc_rec* c) = 0;
73 
74   virtual tSDP_DISC_ATTR* FindAttributeInRec(t_sdp_disc_rec* a, uint16_t b) = 0;
75 
76   virtual bool FindProfileVersionInRec(t_sdp_disc_rec* a, uint16_t b,
77                                        uint16_t* c) = 0;
78 
79   virtual ~SdpInterface() = default;
80 };
81 
82 class A2dpInterface {
83  public:
84   virtual RawAddress active_peer() = 0;
85   virtual bool is_peer_in_silence_mode(const RawAddress& peer_address) = 0;
86 
87   virtual ~A2dpInterface() = default;
88 };
89