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