bluetooth_headset_callbacks.h 5.8 KB

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