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

Commit 8572d792 authored by Zhihai Xu's avatar Zhihai Xu
Browse files

Add debug menu to enable btsnoop

bug: 8059358
Change-Id: I232f6d47e7fb7e9c4d71c119394fce3e72cd02fc
parent b4c0c5a4
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -335,4 +335,15 @@ bt_status_t btif_dut_mode_send(uint16_t opcode, uint8_t *buf, uint8_t len);
**
*******************************************************************************/
bt_status_t btif_le_test_mode(uint16_t opcode, uint8_t *buf, uint8_t len);

/*******************************************************************************
**
** Function         btif_config_hci_snoop_log
**
** Description     enable or disable HCI snoop log
**
** Returns          BT_STATUS_SUCCESS on success
**
*******************************************************************************/
bt_status_t btif_config_hci_snoop_log(uint8_t enable);
#endif /* BTIF_API_H */
+14 −2
Original line number Diff line number Diff line
@@ -372,6 +372,17 @@ int le_test_mode(uint16_t opcode, uint8_t* buf, uint8_t len)
}
#endif

int config_hci_snoop_log(uint8_t enable)
{
    ALOGI("config_hci_snoop_log");

    /* sanity check */
    if (interface_ready() == FALSE)
        return BT_STATUS_NOT_READY;

    return btif_config_hci_snoop_log(enable);
}

static const bt_interface_t bluetoothInterface = {
    sizeof(bluetoothInterface),
    init,
@@ -397,10 +408,11 @@ static const bt_interface_t bluetoothInterface = {
    dut_mode_configure,
    dut_mode_send,
#if BLE_INCLUDED == TRUE
    le_test_mode
    le_test_mode,
#else
    NULL
    NULL,
#endif
    config_hci_snoop_log
};

const bt_interface_t* bluetooth__get_bluetooth_interface ()
+17 −0
Original line number Diff line number Diff line
@@ -141,6 +141,7 @@ void btif_dm_execute_service_request(UINT16 event, char *p_param);
#ifdef BTIF_DM_OOB_TEST
void btif_dm_load_local_oob(void);
#endif
void bte_main_config_hci_logging(BOOLEAN enable, BOOLEAN bt_disabled);

/************************************************************************************
**  Functions
@@ -1460,3 +1461,19 @@ bt_status_t btif_disable_service(tBTA_SERVICE_ID service_id)

    return BT_STATUS_SUCCESS;
}

/*******************************************************************************
**
** Function         btif_config_hci_snoop_log
**
** Description      enable or disable HCI snoop log
**
** Returns          bt_status_t
**
*******************************************************************************/
bt_status_t btif_config_hci_snoop_log(uint8_t enable)
{
    bte_main_config_hci_logging(enable != 0,
             btif_core_state == BTIF_CORE_STATE_DISABLED);
    return BT_STATUS_SUCCESS;
}
+32 −2
Original line number Diff line number Diff line
@@ -76,6 +76,7 @@ typedef struct
**  Variables
******************************************************************************/
BOOLEAN hci_logging_enabled = FALSE;    /* by default, turn hci log off */
BOOLEAN hci_logging_config = FALSE;    /* configured from bluetooth framework */
char hci_logfile[256] = HCI_LOGGING_FILENAME;


@@ -225,6 +226,35 @@ void bte_main_disable(void)
    GKI_freeze();
}

/******************************************************************************
**
** Function         bte_main_config_hci_logging
**
** Description      enable or disable HIC snoop logging
**
** Returns          None
**
******************************************************************************/
void bte_main_config_hci_logging(BOOLEAN enable, BOOLEAN bt_disabled)
{
    int old = (hci_logging_enabled == TRUE) || (hci_logging_config == TRUE);
    int new;

    if (enable) {
        hci_logging_config = TRUE;
    } else {
        hci_logging_config = FALSE;
    }

    new = (hci_logging_enabled == TRUE) || (hci_logging_config == TRUE);

    if ((old == new) || bt_disabled || (bt_hc_if == NULL)) {
        return;
    }

    bt_hc_if->logging(new ? BT_HC_LOGGING_ON : BT_HC_LOGGING_OFF, hci_logfile);
}

/******************************************************************************
**
** Function         bte_hci_enable
@@ -247,7 +277,7 @@ static void bte_hci_enable(void)

        assert(result == BT_HC_STATUS_SUCCESS);

        if (hci_logging_enabled == TRUE)
        if (hci_logging_enabled == TRUE || hci_logging_config == TRUE)
            bt_hc_if->logging(BT_HC_LOGGING_ON, hci_logfile);

#if (defined (BT_CLEAN_TURN_ON_DISABLED) && BT_CLEAN_TURN_ON_DISABLED == TRUE)
@@ -291,7 +321,7 @@ static void bte_hci_disable(void)
    {
        bt_hc_if->cleanup();
        bt_hc_if->set_power(BT_HC_CHIP_PWR_OFF);
        if (hci_logging_enabled == TRUE)
        if (hci_logging_enabled == TRUE ||  hci_logging_config == TRUE)
            bt_hc_if->logging(BT_HC_LOGGING_OFF, hci_logfile);
    }
}