1 /* 2 * Copyright 2017 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 <raw_address.h> 20 21 #include "bt_hf.h" 22 23 namespace bluetooth { 24 namespace headset { 25 26 /** 27 * Headset related callbacks invoked from from the Bluetooth native stack 28 * All callbacks are invoked on the JNI thread 29 */ 30 class Callbacks { 31 public: 32 virtual ~Callbacks() = default; 33 /** 34 * Callback for connection state change. 35 * 36 * @param state one of the values from bthf_connection_state_t 37 * @param bd_addr remote device address 38 */ 39 virtual void ConnectionStateCallback(bthf_connection_state_t state, 40 RawAddress* bd_addr) = 0; 41 42 /** 43 * Callback for audio connection state change. 44 * 45 * @param state one of the values from bthf_audio_state_t 46 * @param bd_addr remote device address 47 */ 48 virtual void AudioStateCallback(bthf_audio_state_t state, 49 RawAddress* bd_addr) = 0; 50 51 /** 52 * Callback for VR connection state change. 53 * 54 * @param state one of the values from bthf_vr_state_t 55 * @param bd_addr 56 */ 57 virtual void VoiceRecognitionCallback(bthf_vr_state_t state, 58 RawAddress* bd_addr) = 0; 59 60 /** 61 * Callback for answer incoming call (ATA) 62 * 63 * @param bd_addr remote device address 64 */ 65 virtual void AnswerCallCallback(RawAddress* bd_addr) = 0; 66 67 /** 68 * Callback for disconnect call (AT+CHUP) 69 * 70 * @param bd_addr remote device address 71 */ 72 virtual void HangupCallCallback(RawAddress* bd_addr) = 0; 73 74 /** 75 * Callback for disconnect call (AT+CHUP) 76 * 77 * @param type denote Speaker/Mic gain bthf_volume_type_t 78 * @param volume volume value 0 to 15, p69, HFP 1.7.1 spec 79 * @param bd_addr remote device address 80 */ 81 virtual void VolumeControlCallback(bthf_volume_type_t type, int volume, 82 RawAddress* bd_addr) = 0; 83 84 /** 85 * Callback for dialing an outgoing call 86 * 87 * @param number intended phone number, if number is NULL, redial 88 * @param bd_addr remote device address 89 */ 90 virtual void DialCallCallback(char* number, RawAddress* bd_addr) = 0; 91 92 /** 93 * Callback for sending DTMF tones 94 * 95 * @param tone contains the dtmf character to be sent 96 * @param bd_addr remote device address 97 */ 98 virtual void DtmfCmdCallback(char tone, RawAddress* bd_addr) = 0; 99 100 /** 101 * Callback for enabling/disabling noise reduction/echo cancellation 102 * 103 * @param nrec 1 to enable, 0 to disable 104 * @param bd_addr remote device address 105 */ 106 virtual void NoiseReductionCallback(bthf_nrec_t nrec, 107 RawAddress* bd_addr) = 0; 108 109 /** 110 * Callback for AT+BCS and event from BAC 111 * 112 * @param wbs WBS enable, WBS disable 113 * @param bd_addr remote device address 114 */ 115 virtual void WbsCallback(bthf_wbs_config_t wbs, RawAddress* bd_addr) = 0; 116 117 /** 118 * Callback for AT+BCS and event from BAC 119 * 120 * @param codec SWB codec 121 * @param swb SWB enable, SWB disable 122 * @param bd_addr remote device address 123 */ 124 virtual void SwbCallback(bthf_swb_codec_t codec, bthf_swb_config_t swb, 125 RawAddress* bd_addr) = 0; 126 127 /** 128 * Callback for call hold handling (AT+CHLD) 129 * 130 * @param chld the call hold command (0, 1, 2, 3) 131 * @param bd_addr remote device address 132 */ 133 virtual void AtChldCallback(bthf_chld_type_t chld, RawAddress* bd_addr) = 0; 134 135 /** 136 * Callback for CNUM (subscriber number) 137 * 138 * @param bd_addr remote device address 139 */ 140 virtual void AtCnumCallback(RawAddress* bd_addr) = 0; 141 142 /** 143 * Callback for indicators (CIND) 144 * 145 * @param bd_addr remote device address 146 */ 147 virtual void AtCindCallback(RawAddress* bd_addr) = 0; 148 149 /** 150 * Callback for operator selection (COPS) 151 * 152 * @param bd_addr remote device address 153 */ 154 virtual void AtCopsCallback(RawAddress* bd_addr) = 0; 155 156 /** 157 * Callback for call list (AT+CLCC) 158 * 159 * @param bd_addr remote device address 160 */ 161 virtual void AtClccCallback(RawAddress* bd_addr) = 0; 162 163 /** 164 * Callback for unknown AT command recd from HF 165 * 166 * @param at_string he unparsed AT string 167 * @param bd_addr remote device address 168 */ 169 virtual void UnknownAtCallback(char* at_string, RawAddress* bd_addr) = 0; 170 171 /** 172 * Callback for keypressed (HSP) event. 173 * 174 * @param bd_addr remote device address 175 */ 176 virtual void KeyPressedCallback(RawAddress* bd_addr) = 0; 177 178 /** 179 * Callback for BIND. Pass the remote HF Indicators supported. 180 * 181 * @param at_string unparsed AT command string 182 * @param bd_addr remote device address 183 */ 184 virtual void AtBindCallback(char* at_string, RawAddress* bd_addr) = 0; 185 186 /** 187 * Callback for BIEV. Pass the change in the Remote HF indicator values 188 * 189 * @param ind_id HF indicator id 190 * @param ind_value HF indicator value 191 * @param bd_addr remote device address 192 */ 193 virtual void AtBievCallback(bthf_hf_ind_type_t ind_id, int ind_value, 194 RawAddress* bd_addr) = 0; 195 196 /** 197 * Callback for BIA. Pass the change in AG indicator activation. 198 * NOTE: Call, Call Setup and Call Held indicators are mandatory and cannot 199 * be disabled. Thus, they are not included here. 200 * 201 * @param service whether HF should receive network service state update 202 * @param roam whether HF should receive roaming state update 203 * @param signal whether HF should receive signal strength update 204 * @param battery whether HF should receive AG battery level update 205 * @param bd_addr remote HF device address 206 */ 207 virtual void AtBiaCallback(bool service, bool roam, bool signal, bool battery, 208 RawAddress* bd_addr) = 0; 209 210 /** 211 * Callback for DebugDump. 212 * 213 * @param active whether the SCO is active 214 * @param codec_id the codec ID per spec: mSBC=2, LC3=3. 215 * @param total_num_decoded_frames the number of frames decoded. 216 * @param pkt_loss_ratio the ratio of lost frames 217 * @param begin_ts time of the packet status window starts in microseconds. 218 * @param end_ts time of the packet status window ends in microseconds. 219 * @param pkt_status_in_hex recorded packets' status in hex string. 220 * @param pkt_status_in_binary recorde packets' status in binary string. 221 */ 222 virtual void DebugDumpCallback(bool active, uint16_t codec_id, 223 int total_num_decoded_frames, 224 double pkt_loss_ratio, uint64_t begin_ts, 225 uint64_t end_ts, const char* pkt_status_in_hex, 226 const char* pkt_status_in_binary) = 0; 227 }; 228 229 } // namespace headset 230 } // namespace bluetooth 231