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

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

Merge "Replace BTM_DEF_LOCAL_NAME with the new stable sysprop value"

parents d6c6f8f7 20eb2d82
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -179,6 +179,9 @@ cc_defaults {
                "libfmq",
                "libstatslog_bt",
            ],
            whole_static_libs: [
                "PlatformProperties",
            ],
            srcs: ["src/btif_avrcp_audio_track.cc"],
        },
        host: {
+24 −3
Original line number Diff line number Diff line
@@ -29,6 +29,10 @@

#include "btif_dm.h"

#ifdef OS_ANDROID
#include <android/sysprop/BluetoothProperties.sysprop.h>
#endif

#include <base/bind.h>
#include <base/logging.h>
#include <bluetooth/uuid.h>
@@ -117,6 +121,9 @@ const bool enable_address_consolidate = true; // TODO remove
#define BTIF_DM_MAX_SDP_ATTEMPTS_AFTER_PAIRING 2

#define NUM_TIMEOUT_RETRIES 5
#ifndef PROPERTY_DEFAULT_DEVICE_NAME
#define PROPERTY_DEFAULT_DEVICE_NAME "bluetooth.device.default_name"
#endif
#ifndef PROPERTY_PRODUCT_MODEL
#define PROPERTY_PRODUCT_MODEL "ro.product.model"
#endif
@@ -3083,9 +3090,23 @@ void btif_dm_read_energy_info() { BTA_DmBleGetEnergyInfo(bta_energy_info_cb); }
static const char* btif_get_default_local_name() {
  if (btif_default_local_name[0] == '\0') {
    int max_len = sizeof(btif_default_local_name) - 1;
    if (BTM_DEF_LOCAL_NAME[0] != '\0') {
      strncpy(btif_default_local_name, BTM_DEF_LOCAL_NAME, max_len);
    } else {

    // Use the stable sysprop on Android devices, otherwise use osi_property_get
#ifdef OS_ANDROID
    std::optional<std::string> default_local_name =
        android::sysprop::BluetoothProperties::getDefaultDeviceName();
    if (default_local_name.has_value() && default_local_name.value() != "") {
      strncpy(btif_default_local_name, default_local_name.value().c_str(),
              max_len);
    }
#else
    char prop_name[PROPERTY_VALUE_MAX];
    osi_property_get(PROPERTY_DEFAULT_DEVICE_NAME, prop_name, "");
    strncpy(btif_default_local_name, prop_name, max_len);
#endif

    // If no value was placed in the btif_default_local_name then use model name
    if (btif_default_local_name[0] == '\0') {
      char prop_model[PROPERTY_VALUE_MAX];
      osi_property_get(PROPERTY_PRODUCT_MODEL, prop_model, "");
      strncpy(btif_default_local_name, prop_model, max_len);
+0 −7
Original line number Diff line number Diff line
@@ -340,13 +340,6 @@
#define BTM_MAX_LOC_BD_NAME_LEN 248
#endif

/* Fixed Default String. When this is defined as null string, the device's
 * product model name is used as the default local name.
 */
#ifndef BTM_DEF_LOCAL_NAME
#define BTM_DEF_LOCAL_NAME ""
#endif

/* Maximum service name stored with security authorization (0 if not needed) */
#ifndef BTM_SEC_SERVICE_NAME_LEN
#define BTM_SEC_SERVICE_NAME_LEN BT_MAX_SERVICE_NAME_LEN