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

Commit 3e9ee649 authored by Dorin Drimus's avatar Dorin Drimus Committed by Gerrit Code Review
Browse files

Merge "Use bluetooth.core.gap.le.privacy.enabled sysprop to init BLE Privacy"

parents 990dafe1 573de7b6
Loading
Loading
Loading
Loading
+25 −2
Original line number Diff line number Diff line
@@ -51,6 +51,10 @@

#include <mutex>

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

#include "advertise_data_parser.h"
#include "bta_csis_api.h"
#include "bta_dm_int.h"
@@ -132,6 +136,10 @@ const bool enable_address_consolidate = true; // TODO remove
#error "default btif local name size exceeds stack supported length"
#endif

#ifndef PROPERTY_BLE_PRIVACY_ENABLED
#define PROPERTY_BLE_PRIVACY_ENABLED "bluetooth.core.gap.le.privacy.enabled"
#endif

#define ENCRYPTED_BREDR 2
#define ENCRYPTED_LE 4

@@ -1543,8 +1551,23 @@ void BTIF_dm_enable() {
    BTA_DmSetDeviceName(btif_get_default_local_name());
  }

  /* Enable local privacy */
  BTA_DmBleConfigLocalPrivacy(BLE_LOCAL_PRIVACY_ENABLED);
  /* Enable or disable local privacy */
  bool ble_privacy_enabled = true;
  #ifdef OS_ANDROID
    ble_privacy_enabled =
        android::sysprop::BluetoothProperties::isGapLePrivacyEnabled().value_or(
            true);
  #else
    char ble_privacy_text[PROPERTY_VALUE_MAX] = "true";  // default is enabled
    if (osi_property_get(PROPERTY_BLE_PRIVACY_ENABLED, ble_privacy_text,
                         "true") &&
        !strcmp(ble_privacy_text, "false")) {
      ble_privacy_enabled = false;
    }
  #endif

  LOG_INFO("%s BLE Privacy: %d", __func__, ble_privacy_enabled);
  BTA_DmBleConfigLocalPrivacy(ble_privacy_enabled);

  /* for each of the enabled services in the mask, trigger the profile
   * enable */
+16 −5
Original line number Diff line number Diff line
@@ -76,15 +76,26 @@

// Validate or respond to various conditional compilation flags

#if BLE_PRIVACY_SPT != TRUE
// Once BLE_PRIVACY_SPT is no longer exposed via bt_target.h
// this check and error statement may be removed.
#ifdef BLE_PRIVACY_SPT
// When BLE_PRIVACY_SPT is not used anymore this check and error statement may be removed.
#warning \
    "#define BLE_PRIVACY_SPT FALSE preprocessor compilation flag is unsupported"
    "#define BLE_PRIVACY_SPT FALSE preprocessor compilation flag is no longer used"
#warning \
    "  To disable LE privacy for a device use: #define BLE_LOCAL_PRIVACY_ENABLED FALSE"
    "  To disable LE privacy for a device \
set 'bluetooth.core.gap.le.privacy.enabled' sysprop to false"
#if BLE_PRIVACY_SPT == FALSE
#error "*** Conditional Compilation Directive error"
#endif
#endif

#ifdef BLE_LOCAL_PRIVACY_ENABLED
// When BLE_PRIVACY_SPT is not used anymore this warning statement may be removed.
#warning \
    "#define BLE_LOCAL_PRIVACY_ENABLED FALSE preprocessor compilation flag is no longer used"
#warning \
    "  To disable LE privacy for a device \
set 'bluetooth.core.gap.le.privacy.enabled sysprop' to false"
#endif

#if SDP_RAW_DATA_INCLUDED != TRUE
// Once SDP_RAW_DATA_INCLUDED is no longer exposed via bt_target.h
+0 −15
Original line number Diff line number Diff line
@@ -524,21 +524,6 @@
#define LOCAL_BLE_CONTROLLER_ID 1
#endif

/*
 * Toggles support for general LE privacy features such as remote address
 * resolution, local address rotation etc.
 */
#ifndef BLE_PRIVACY_SPT
#define BLE_PRIVACY_SPT TRUE
#endif

/*
 * Enables or disables support for local privacy (ex. address rotation)
 */
#ifndef BLE_LOCAL_PRIVACY_ENABLED
#define BLE_LOCAL_PRIVACY_ENABLED TRUE
#endif

/*
 * Toggles support for vendor specific extensions such as RPA offloading,
 * feature discovery, multi-adv etc.