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