Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f5243eb8 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Implement bluetooth interface functions to check if a headset supports...

Merge "Implement bluetooth interface functions to check if a headset supports voice recognition as well as echo cancellation and/or noise reduction"
parents 169219ef 7879e381
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -65,4 +65,7 @@ interface IBluetoothHeadset {
    boolean isInbandRingingEnabled();
    boolean setPriority(in BluetoothDevice device, int connectionPolicy);
    int getPriority(in BluetoothDevice device);

    boolean isNoiseReductionSupported(in BluetoothDevice device);
    boolean isVoiceRecognitionSupported(in BluetoothDevice device);
}
+28 −0
Original line number Diff line number Diff line
@@ -711,6 +711,8 @@ class HeadsetInterface : Interface {
  bt_status_t Disconnect(RawAddress* bd_addr) override;
  bt_status_t ConnectAudio(RawAddress* bd_addr) override;
  bt_status_t DisconnectAudio(RawAddress* bd_addr) override;
  bt_status_t isNoiseReductionSupported(RawAddress* bd_addr) override;
  bt_status_t isVoiceRecognitionSupported(RawAddress* bd_addr) override;
  bt_status_t StartVoiceRecognition(RawAddress* bd_addr) override;
  bt_status_t StopVoiceRecognition(RawAddress* bd_addr) override;
  bt_status_t VolumeControl(bthf_volume_type_t type, int volume,
@@ -835,6 +837,32 @@ bt_status_t HeadsetInterface::DisconnectAudio(RawAddress* bd_addr) {
  return BT_STATUS_SUCCESS;
}

bt_status_t HeadsetInterface::isNoiseReductionSupported(RawAddress* bd_addr) {
  CHECK_BTHF_INIT();
  int idx = btif_hf_idx_by_bdaddr(bd_addr);
  if ((idx < 0) || (idx >= BTA_AG_MAX_NUM_CLIENTS)) {
    BTIF_TRACE_ERROR("%s: Invalid index %d", __func__, idx);
    return BT_STATUS_FAIL;
  }
  if (!(btif_hf_cb[idx].peer_feat & BTA_AG_PEER_FEAT_ECNR)) {
    return BT_STATUS_UNSUPPORTED;
  }
  return BT_STATUS_SUCCESS;
}

bt_status_t HeadsetInterface::isVoiceRecognitionSupported(RawAddress* bd_addr) {
  CHECK_BTHF_INIT();
  int idx = btif_hf_idx_by_bdaddr(bd_addr);
  if ((idx < 0) || (idx >= BTA_AG_MAX_NUM_CLIENTS)) {
    BTIF_TRACE_ERROR("%s: Invalid index %d", __func__, idx);
    return BT_STATUS_FAIL;
  }
  if (!(btif_hf_cb[idx].peer_feat & BTA_AG_PEER_FEAT_VREC)) {
    return BT_STATUS_UNSUPPORTED;
  }
  return BT_STATUS_SUCCESS;
}

bt_status_t HeadsetInterface::StartVoiceRecognition(RawAddress* bd_addr) {
  CHECK_BTHF_INIT();
  int idx = btif_hf_idx_by_bdaddr(bd_addr);
+18 −0
Original line number Diff line number Diff line
@@ -72,6 +72,24 @@ class Interface {
   */
  virtual bt_status_t DisconnectAudio(RawAddress* bd_addr) = 0;

  /**
   * Checks whether the device support echo cancellation and/or noise reduction
   * via the AT+BRSF bitmask
   *
   * @param bd_addr remote device address
   * @return BT_STATUS_SUCCESS on success
   */
  virtual bt_status_t isNoiseReductionSupported(RawAddress* bd_addr) = 0;

  /**
   * Checks whether the device supports voice recognition via the AT+BRSF
   * bitmask
   *
   * @param bd_addr remote device address
   * @return BT_STATUS_SUCCESS on success
   */
  virtual bt_status_t isVoiceRecognitionSupported(RawAddress* bd_addr) = 0;

  /** start voice recognition */
  /**
   * Start voice recognition