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