• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 swb SWB enable, SWB disable
121    * @param bd_addr remote device address
122    */
123   virtual void SwbCallback(bthf_swb_config_t swb, RawAddress* bd_addr) = 0;
124 
125   /**
126    * Callback for call hold handling (AT+CHLD)
127    *
128    * @param chld the call hold command (0, 1, 2, 3)
129    * @param bd_addr remote device address
130    */
131   virtual void AtChldCallback(bthf_chld_type_t chld, RawAddress* bd_addr) = 0;
132 
133   /**
134    * Callback for CNUM (subscriber number)
135    *
136    * @param bd_addr remote device address
137    */
138   virtual void AtCnumCallback(RawAddress* bd_addr) = 0;
139 
140   /**
141    * Callback for indicators (CIND)
142    *
143    * @param bd_addr remote device address
144    */
145   virtual void AtCindCallback(RawAddress* bd_addr) = 0;
146 
147   /**
148    * Callback for operator selection (COPS)
149    *
150    * @param bd_addr remote device address
151    */
152   virtual void AtCopsCallback(RawAddress* bd_addr) = 0;
153 
154   /**
155    * Callback for call list (AT+CLCC)
156    *
157    * @param bd_addr remote device address
158    */
159   virtual void AtClccCallback(RawAddress* bd_addr) = 0;
160 
161   /**
162    * Callback for unknown AT command recd from HF
163    *
164    * @param at_string he unparsed AT string
165    * @param bd_addr remote device address
166    */
167   virtual void UnknownAtCallback(char* at_string, RawAddress* bd_addr) = 0;
168 
169   /**
170    * Callback for keypressed (HSP) event.
171    *
172    * @param bd_addr remote device address
173    */
174   virtual void KeyPressedCallback(RawAddress* bd_addr) = 0;
175 
176   /**
177    * Callback for BIND. Pass the remote HF Indicators supported.
178    *
179    * @param at_string unparsed AT command string
180    * @param bd_addr remote device address
181    */
182   virtual void AtBindCallback(char* at_string, RawAddress* bd_addr) = 0;
183 
184   /**
185    * Callback for BIEV. Pass the change in the Remote HF indicator values
186    *
187    * @param ind_id HF indicator id
188    * @param ind_value HF indicator value
189    * @param bd_addr remote device address
190    */
191   virtual void AtBievCallback(bthf_hf_ind_type_t ind_id, int ind_value,
192                               RawAddress* bd_addr) = 0;
193 
194   /**
195    * Callback for BIA. Pass the change in AG indicator activation.
196    * NOTE: Call, Call Setup and Call Held indicators are mandatory and cannot
197    *       be disabled. Thus, they are not included here.
198    *
199    * @param service whether HF should receive network service state update
200    * @param roam whether HF should receive roaming state update
201    * @param signal whether HF should receive signal strength update
202    * @param battery whether HF should receive AG battery level update
203    * @param bd_addr remote HF device address
204    */
205   virtual void AtBiaCallback(bool service, bool roam, bool signal, bool battery,
206                              RawAddress* bd_addr) = 0;
207 };
208 
209 }  // namespace headset
210 }  // namespace bluetooth
211