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