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

Commit 1acdb04e authored by Jack He's avatar Jack He
Browse files

HFP: Add isInbandRingingEnabled() API (3/4)

* Use BluetoothHeadset.isInbandRingingEnabled() API to check whether
  in-band ringing is currently enabled in the system when deciding on
  audio routes for ringtone
* Use this value obtained in Java layer to initialize native HFP/HSP
  stack instead of checking it in native layer

Bug: 71646213
Test: make, toggle in-band ringing from Development Settings and observe
      whether Telecom service tries to open SCO when there is an
      incoming call

Change-Id: I917537b6d17681151639ff29a56ac9c0c7e0e7e8
parent 6b87071b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -58,4 +58,5 @@ interface IBluetoothHeadset {
                      String number, int type);
    boolean setActiveDevice(in BluetoothDevice device);
    BluetoothDevice getActiveDevice();
    boolean isInbandRingingEnabled();
}
+5 −19
Original line number Diff line number Diff line
@@ -626,17 +626,6 @@ static void bte_hf_evt(tBTA_AG_EVT event, tBTA_AG* p_data) {
  ASSERTC(status == BT_STATUS_SUCCESS, "context transfer failed", status);
}

static bool inband_ringing_property_disabled() {
  char disable_inband_ringing_flag[PROPERTY_VALUE_MAX] = {0};
  osi_property_get("persist.bluetooth.disableinbandringing",
                   disable_inband_ringing_flag, "false");
  if (strncmp(disable_inband_ringing_flag, "true", 4) == 0) {
    BTIF_TRACE_DEBUG("%s: In-band ringing disabled by property", __func__);
    return true;
  }
  return false;
}

/*******************************************************************************
 *
 * Function         connect
@@ -699,7 +688,7 @@ class HeadsetInterface : Interface {
    return instance;
  }
  bt_status_t Init(Callbacks* callbacks, int max_hf_clients,
                   bool inband_ringing_supported) override;
                   bool inband_ringing_enabled) override;
  bt_status_t Connect(RawAddress* bd_addr) override;
  bt_status_t Disconnect(RawAddress* bd_addr) override;
  bt_status_t ConnectAudio(RawAddress* bd_addr) override;
@@ -737,19 +726,16 @@ class HeadsetInterface : Interface {
};

bt_status_t HeadsetInterface::Init(Callbacks* callbacks, int max_hf_clients,
                                   bool inband_ringing_supported) {
  bool inband_ringing_property_disable = inband_ringing_property_disabled();
  if (inband_ringing_supported && !inband_ringing_property_disable) {
                                   bool inband_ringing_enabled) {
  if (inband_ringing_enabled) {
    btif_hf_features |= BTA_AG_FEAT_INBAND;
  } else {
    btif_hf_features &= ~BTA_AG_FEAT_INBAND;
  }
  btif_max_hf_clients = max_hf_clients;
  BTIF_TRACE_DEBUG(
      "%s: btif_hf_features=%zu, max_hf_clients=%d, "
      "inband_ringing=[supported=%d, enabled=%d]",
      __func__, btif_hf_features, btif_max_hf_clients, inband_ringing_supported,
      !inband_ringing_property_disable);
      "%s: btif_hf_features=%zu, max_hf_clients=%d, inband_ringing_enabled=%d",
      __func__, btif_hf_features, btif_max_hf_clients, inband_ringing_enabled);
  bt_hf_callbacks = callbacks;
  for (btif_hf_cb_t& hf_cb : btif_hf_cb) {
    hf_cb = {};
+2 −3
Original line number Diff line number Diff line
@@ -34,12 +34,11 @@ class Interface {
   *
   * @param callbacks callbacks for the user of the native stack
   * @param max_hf_clients maximum number of headset clients
   * @param inband_ringing_supported whether inband ringtone is supported by
   * the platform hardware
   * @param inband_ringing_enabled whether inband ringtone is enabled
   * @return BT_STATUS_SUCCESS on success
   */
  virtual bt_status_t Init(Callbacks* callbacks, int max_hf_clients,
                           bool inband_ringing_supported) = 0;
                           bool inband_ringing_enabled) = 0;

  /**
   * Connect to headset