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

Commit 43d82438 authored by William Escande's avatar William Escande Committed by Automerger Merge Worker
Browse files

Merge changes from topic "cherrypicker-L13700000958927953:N69400001343558341"...

Merge changes from topic "cherrypicker-L13700000958927953:N69400001343558341" into tm-qpr-dev am: b9d0c19d

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/21795420



Change-Id: I8c51e4bcb43d8e435cfbc1ef6737f2afe44668ae
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 2c01e6e9 b9d0c19d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@ sysprop_library {
  srcs: [
    "avrcp.sysprop",
    "bta.sysprop",
    "hfp.sysprop",
  ],
  property_owner: "Platform",
  api_packages: ["android.sysprop"],

sysprop/hfp.sysprop

0 → 100644
+12 −0
Original line number Diff line number Diff line
module: "android.sysprop.bluetooth.Hfp"
owner: Platform

prop {
    api_name: "hf_services"
    type: Integer
    scope: Internal
    access: Readonly
    prop_name: "bluetooth.hfp.hf_services_mask.config"
}

+1 −0
Original line number Diff line number Diff line
@@ -176,6 +176,7 @@ cc_defaults {
        "lib-bt-packets-base",
        "lib-bt-packets-avrcp",
        "libbt-audio-hal-interface",
        "libcom.android.sysprop.bluetooth",
        "libaudio-a2dp-hw-utils",
    ],
    cflags: [
+31 −18
Original line number Diff line number Diff line
@@ -27,6 +27,10 @@

#define LOG_TAG "bt_btif_hf"

#ifdef OS_ANDROID
#include <hfp.sysprop.h>
#endif

#include <cstdint>
#include <string>

@@ -64,10 +68,6 @@ namespace headset {
#define BTIF_HFAG_SERVICE_NAME ("Handsfree Gateway")
#endif

#ifndef BTIF_HF_SERVICES
#define BTIF_HF_SERVICES (BTA_HSP_SERVICE_MASK | BTA_HFP_SERVICE_MASK)
#endif

#ifndef BTIF_HF_SERVICE_NAMES
#define BTIF_HF_SERVICE_NAMES \
  { BTIF_HSAG_SERVICE_NAME, BTIF_HFAG_SERVICE_NAME }
@@ -145,6 +145,17 @@ static bool is_active_device(const RawAddress& bd_addr) {
  return !active_bda.IsEmpty() && active_bda == bd_addr;
}

static tBTA_SERVICE_MASK get_BTIF_HF_SERVICES() {
#ifdef OS_ANDROID
  static const tBTA_SERVICE_MASK hf_services =
      android::sysprop::bluetooth::Hfp::hf_services().value_or(
          BTA_HSP_SERVICE_MASK | BTA_HFP_SERVICE_MASK);
  return hf_services;
#else
  return BTA_HSP_SERVICE_MASK | BTA_HFP_SERVICE_MASK;
#endif
}

/*******************************************************************************
 *
 * Function         is_connected
@@ -773,11 +784,11 @@ bt_status_t HeadsetInterface::Init(Callbacks* callbacks, int max_hf_clients,
// Invoke the enable service API to the core to set the appropriate service_id
// Internally, the HSP_SERVICE_ID shall also be enabled if HFP is enabled
// (phone) otherwise only HSP is enabled (tablet)
#if (defined(BTIF_HF_SERVICES) && (BTIF_HF_SERVICES & BTA_HFP_SERVICE_MASK))
  if (get_BTIF_HF_SERVICES() & BTA_HFP_SERVICE_MASK) {
    btif_enable_service(BTA_HFP_SERVICE_ID);
#else
  } else {
    btif_enable_service(BTA_HSP_SERVICE_ID);
#endif
  }

  return BT_STATUS_SUCCESS;
}
@@ -1401,15 +1412,16 @@ void HeadsetInterface::Cleanup() {
  btif_queue_cleanup(UUID_SERVCLASS_AG_HANDSFREE);

  tBTA_SERVICE_MASK mask = btif_get_enabled_services_mask();
#if (defined(BTIF_HF_SERVICES) && (BTIF_HF_SERVICES & BTA_HFP_SERVICE_MASK))
  if (get_BTIF_HF_SERVICES() & BTA_HFP_SERVICE_MASK) {
    if ((mask & (1 << BTA_HFP_SERVICE_ID)) != 0) {
      btif_disable_service(BTA_HFP_SERVICE_ID);
    }
#else
  } else {
    if ((mask & (1 << BTA_HSP_SERVICE_ID)) != 0) {
      btif_disable_service(BTA_HSP_SERVICE_ID);
    }
#endif
  }

  do_in_jni_thread(FROM_HERE, base::Bind([]() { bt_hf_callbacks = nullptr; }));
}

@@ -1466,7 +1478,8 @@ bt_status_t ExecuteService(bool b_enable) {
    /* Enable and register with BTA-AG */
    BTA_AgEnable(bte_hf_evt);
    for (uint8_t app_id = 0; app_id < btif_max_hf_clients; app_id++) {
      BTA_AgRegister(BTIF_HF_SERVICES, btif_hf_features, service_names, app_id);
      BTA_AgRegister(get_BTIF_HF_SERVICES(), btif_hf_features, service_names,
                     app_id);
    }
  } else {
    /* De-register AG */