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