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

Commit 06f7bd00 authored by Dorin Drimus's avatar Dorin Drimus
Browse files

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

Replace BLE_LOCAL_PRIVACY_ENABLED with the
bluetooth.core.gap.le.privacy.enabled sysprop from BluetoothProperties.
This enables mainline builds to take BT configurations from the vendor
set sysprops.

Bug: 227605076
Test: build and run adt3-userdebug
(cherry-picked from aosp/2062291)

Change-Id: Ifba555363d37f6d62387911fb97cb230b4551ac4
Merged-In: I0041f2d7bb39a3130d6efc47a509f9223954e8c1
parent 4120077e
Loading
Loading
Loading
Loading
+24 −2
Original line number Original line Diff line number Diff line
@@ -51,6 +51,10 @@


#include <mutex>
#include <mutex>


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

#include "advertise_data_parser.h"
#include "advertise_data_parser.h"
#include "bta_csis_api.h"
#include "bta_csis_api.h"
#include "bta_dm_int.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"
#error "default btif local name size exceeds stack supported length"
#endif
#endif


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

#define ENCRYPTED_BREDR 2
#define ENCRYPTED_BREDR 2
#define ENCRYPTED_LE 4
#define ENCRYPTED_LE 4


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


  /* Enable local privacy */
  /* Enable or disable local privacy */
  BTA_DmBleConfigLocalPrivacy(BLE_LOCAL_PRIVACY_ENABLED);
  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
  /* for each of the enabled services in the mask, trigger the profile
   * enable */
   * enable */
+16 −5
Original line number Original line Diff line number Diff line
@@ -76,15 +76,26 @@


// Validate or respond to various conditional compilation flags
// Validate or respond to various conditional compilation flags


#if BLE_PRIVACY_SPT != TRUE
#ifdef BLE_PRIVACY_SPT
// Once BLE_PRIVACY_SPT is no longer exposed via bt_target.h
// When BLE_PRIVACY_SPT is not used anymore this check and error statement may be removed.
// this check and error statement may be removed.
#warning \
#warning \
    "#define BLE_PRIVACY_SPT FALSE preprocessor compilation flag is unsupported"
    "#define BLE_PRIVACY_SPT FALSE preprocessor compilation flag is no longer used"
#warning \
#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"
#error "*** Conditional Compilation Directive error"
#endif
#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
#if SDP_RAW_DATA_INCLUDED != TRUE
// Once SDP_RAW_DATA_INCLUDED is no longer exposed via bt_target.h
// Once SDP_RAW_DATA_INCLUDED is no longer exposed via bt_target.h
+0 −15
Original line number Original line Diff line number Diff line
@@ -524,21 +524,6 @@
#define LOCAL_BLE_CONTROLLER_ID 1
#define LOCAL_BLE_CONTROLLER_ID 1
#endif
#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,
 * Toggles support for vendor specific extensions such as RPA offloading,
 * feature discovery, multi-adv etc.
 * feature discovery, multi-adv etc.