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

Commit 364d1b60 authored by Jakub Pawlowski's avatar Jakub Pawlowski Committed by android-build-merger
Browse files

Add advertising handle zero quirk

am: f33ade65

Change-Id: I520cd3d1aff332d9eb0ccce13f36dc0aceb2f25e
parents 02114d98 f33ade65
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
#include <utility>
#include "btm_api.h"
#include "btm_ble_api.h"
#include "btm_int_types.h"
#include "device/include/controller.h"

#define BTM_BLE_MULTI_ADV_SET_RANDOM_ADDR_LEN 8
@@ -203,6 +204,19 @@ class BleAdvertiserVscHciInterfaceImpl : public BleAdvertiserHciInterface {
               command_complete);
  }

  bool QuirkAdvertiserZeroHandle() override {
    // Android BT HCI Requirements version 0.96 and below specify that handle 0
    // is equal to standard HCI interface, and should be accessed using non-VSC
    // commands. Broadcom controllers are strict about this requirement, so
    // don't use 0 handle.
    if (BTM_IS_BRCM_CONTROLLER()) {
      LOG(INFO) << "QuirkAdvertiserZeroHandle in use";
      return true;
    }

    return false;
  }

 public:
  static void VendorSpecificEventCback(uint8_t length, uint8_t* p) {
    VLOG(1) << __func__;
+3 −0
Original line number Diff line number Diff line
@@ -71,6 +71,9 @@ class BleAdvertiserHciInterface {
  virtual void Enable(uint8_t enable, uint8_t handle, uint16_t duration,
                      uint8_t max_extended_advertising_events,
                      status_cb command_complete) = 0;

  // Some implementation don't behave well when handle value 0 is used.
  virtual bool QuirkAdvertiserZeroHandle() { return 0; }
};

#endif  // BLE_ADVERTISER_HCI_INTERFACE_H
+6 −0
Original line number Diff line number Diff line
@@ -67,6 +67,7 @@ void btm_ble_adv_raddr_timer_timeout(void* data);
namespace {

void DoNothing(uint8_t) {}
void DoNothing2(uint8_t, uint8_t) {}

std::queue<base::Callback<void(tBTM_RAND_ENC* p)>>* rand_gen_inst_id = nullptr;

@@ -511,6 +512,11 @@ void btm_ble_adv_init() {
  BleAdvertisingManager::Initialize(BleAdvertiserHciInterface::Get());
  BleAdvertiserHciInterface::Get()->SetAdvertisingEventObserver(
      (BleAdvertisingManagerImpl*)BleAdvertisingManager::Get());

  if (BleAdvertiserHciInterface::Get()->QuirkAdvertiserZeroHandle()) {
    // If handle 0 can't be used, register advertiser for it, but never use it.
    BleAdvertisingManager::Get()->RegisterAdvertiser(Bind(DoNothing2));
  }
}

/*******************************************************************************