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

Commit 5fd37a23 authored by David Duarte's avatar David Duarte
Browse files

Revert "Remove unused dut_mode from bluetooth interface"

This reverts commit 0fd84ef2.

Reason for revert: b/269397845

Bug: 269397845
Test: mma
Change-Id: I0bc217670292449e0eab113688a4555833ca4271
parent dd13de3e
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -685,6 +685,10 @@ static void callback_thread_event(bt_cb_thread_evt event) {
  }
}

static void dut_mode_recv_callback(uint16_t opcode, uint8_t* buf, uint8_t len) {

}

static void energy_info_recv_callback(bt_activity_energy_info* p_energy_info,
                                      bt_uid_traffic_t* uid_data) {
  CallbackEnv sCallbackEnv(__func__);
@@ -728,6 +732,7 @@ static bt_callbacks_t sBluetoothCallbacks = {sizeof(sBluetoothCallbacks),
                                             le_address_associate_callback,
                                             acl_state_changed_callback,
                                             callback_thread_event,
                                             dut_mode_recv_callback,
                                             energy_info_recv_callback,
                                             link_quality_report_callback,
                                             generate_local_oob_data_callback,
+6 −0
Original line number Diff line number Diff line
@@ -55,6 +55,12 @@ void BTA_dm_init() {
  BTM_SetConsolidationCallback(bta_dm_consolidate);
}

/** Enables bluetooth device under test mode */
void BTA_EnableTestMode(void) {
  do_in_main_thread(FROM_HERE,
                    base::Bind(base::IgnoreResult(BTM_EnableTestMode)));
}

/** This function sets the Bluetooth name of local device */
void BTA_DmSetDeviceName(const char* p_name) {
  std::vector<uint8_t> name(BD_NAME_LEN + 1);
+12 −0
Original line number Diff line number Diff line
@@ -741,6 +741,18 @@ enum {

void BTA_dm_init();

/*******************************************************************************
 *
 * Function         BTA_EnableTestMode
 *
 * Description      Enables bluetooth device under test mode
 *
 *
 * Returns          tBTA_STATUS
 *
 ******************************************************************************/
extern void BTA_EnableTestMode(void);

/*******************************************************************************
 *
 * Function         BTA_DmSetDeviceName
+21 −0
Original line number Diff line number Diff line
@@ -329,6 +329,27 @@ bt_status_t btif_dm_get_adapter_property(bt_property_t* prop);
 ******************************************************************************/
void btif_dm_get_remote_services(const RawAddress remote_addr, int transport);

/*******************************************************************************
 *
 * Function         btif_dut_mode_configure
 *
 * Description      Configure Test Mode - 'enable' to 1 puts the device in test
 *                  mode and 0 exits test mode
 *
 ******************************************************************************/
void btif_dut_mode_configure(uint8_t enable);

bool btif_is_dut_mode();

/*******************************************************************************
 *
 * Function         btif_dut_mode_send
 *
 * Description     Sends a HCI Vendor specific command to the controller
 *
 ******************************************************************************/
void btif_dut_mode_send(uint16_t opcode, uint8_t* buf, uint8_t len);

/*******************************************************************************
 *
 * Function         btif_dm_read_energy_info
+28 −0
Original line number Diff line number Diff line
@@ -917,6 +917,32 @@ static const void* get_profile_interface(const char* profile_id) {
  return NULL;
}

int dut_mode_configure(uint8_t enable) {
  if (!interface_ready()) return BT_STATUS_NOT_READY;
  if (!stack_manager_get_interface()->get_stack_is_running())
    return BT_STATUS_NOT_READY;

  do_in_main_thread(FROM_HERE, base::BindOnce(btif_dut_mode_configure, enable));
  return BT_STATUS_SUCCESS;
}

int dut_mode_send(uint16_t opcode, uint8_t* buf, uint8_t len) {
  if (!interface_ready()) return BT_STATUS_NOT_READY;
  if (!btif_is_dut_mode()) return BT_STATUS_FAIL;

  uint8_t* copy = (uint8_t*)osi_calloc(len);
  memcpy(copy, buf, len);

  do_in_main_thread(FROM_HERE,
                    base::BindOnce(
                        [](uint16_t opcode, uint8_t* buf, uint8_t len) {
                          btif_dut_mode_send(opcode, buf, len);
                          osi_free(buf);
                        },
                        opcode, copy, len));
  return BT_STATUS_SUCCESS;
}

static bt_os_callouts_t* wakelock_os_callouts_saved = nullptr;

static int acquire_wake_lock_cb(const char* lock_name) {
@@ -1108,6 +1134,8 @@ EXPORT_SYMBOL bt_interface_t bluetoothInterface = {
    .pin_reply = pin_reply,
    .ssp_reply = ssp_reply,
    .get_profile_interface = get_profile_interface,
    .dut_mode_configure = dut_mode_configure,
    .dut_mode_send = dut_mode_send,
    .set_os_callouts = set_os_callouts,
    .read_energy_info = read_energy_info,
    .dump = dump,
Loading