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

Commit 8f6c5beb authored by Andre Eisenbach's avatar Andre Eisenbach
Browse files

Bluetooth native dumpsys logging support (2/5)

Includes support for BTSnoop logging in memory.

Bug: 18508263
Change-Id: I175da528cbcdc00d40622647d518a74210cfe6fd
parent 68489e3d
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -37,6 +37,8 @@
#include "bta_hh_int.h"
#endif

#include "btif/include/btif_debug_conn.h"

#include <string.h>

#include "osi/include/log.h"
@@ -1803,6 +1805,13 @@ static void bta_gattc_conn_cback(tGATT_IF gattc_if, BD_ADDR bda, UINT16 conn_id,
                      __FUNCTION__, gattc_if, connected, conn_id, reason);
    }

    bt_bdaddr_t bdaddr;
    bdcpy(bdaddr.address, bda);
    if (connected)
        btif_debug_conn_state(bdaddr, BTIF_DEBUG_CONNECTED, GATT_CONN_UNKNOWN);
    else
        btif_debug_conn_state(bdaddr, BTIF_DEBUG_DISCONNECTED, reason);

    if ((p_buf = (tBTA_GATTC_DATA *) GKI_getbuf(sizeof(tBTA_GATTC_DATA))) != NULL)
    {
        memset(p_buf, 0, sizeof(tBTA_GATTC_DATA));
+8 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@
#include "bta_gatts_int.h"
#include "bta_gatts_co.h"
#include "btm_ble_api.h"
#include "btif/include/btif_debug_conn.h"
#include <string.h>

static void bta_gatts_nv_save_cback(BOOLEAN is_saved, tGATTS_HNDL_RANGE *p_hndl_range);
@@ -923,6 +924,13 @@ static void bta_gatts_conn_cback (tGATT_IF gatt_if, BD_ADDR bda, UINT16 conn_id,
    APPL_TRACE_DEBUG("bta_gatts_conn_cback  bda :%02x-%02x-%02x-%02x-%02x-%02x ",
                      bda[0],  bda[1], bda[2],  bda[3], bda[4],  bda[5]);

    bt_bdaddr_t bdaddr;
    bdcpy(bdaddr.address, bda);
    if (connected)
        btif_debug_conn_state(bdaddr, BTIF_DEBUG_CONNECTED, GATT_CONN_UNKNOWN);
    else
        btif_debug_conn_state(bdaddr, BTIF_DEBUG_DISCONNECTED, reason);

    p_reg = bta_gatts_find_app_rcb_by_app_if(gatt_if);

    if (p_reg && p_reg->p_cback)
+31 −0
Original line number Diff line number Diff line
/******************************************************************************
 *
 *  Copyright (C) 2015 Google Inc.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at:
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 ******************************************************************************/

#pragma once

#include <stdint.h>

// Debug API

void btif_debug_init(void);
void btif_debug_dump(int fd);

// Debug helpers

// Timestamp in us
uint64_t btif_debug_ts(void);
+43 −0
Original line number Diff line number Diff line
/******************************************************************************
 *
 *  Copyright (C) 2015 Google Inc.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at:
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 ******************************************************************************/

#pragma once

#include <stdint.h>

#define BTSNOOZ_CURRENT_VERSION 0x01

// The preamble is stored un-encrypted as the first part
// of the file.
typedef struct btsnooz_preamble_t {
  uint8_t version;
  uint64_t last_timestamp_ms;
} __attribute__((__packed__)) btsnooz_preamble_t;

// One header for each HCI packet
typedef struct btsnooz_header_t {
  uint16_t length;
  uint32_t delta_time_ms;
  uint8_t type;
} __attribute__((__packed__)) btsnooz_header_t;

// Initializes btsnoop memory logging and registers
void btif_debug_btsnoop_init(void);

// Writes btsnoop data base64 encoded to fd
void btif_debug_btsnoop_dump(int fd);
+34 −0
Original line number Diff line number Diff line
/******************************************************************************
 *
 *  Copyright (C) 2015 Google Inc.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at:
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 ******************************************************************************/

#pragma once

#include <hardware/bluetooth.h>

#include "gatt_api.h"

typedef enum {
  BTIF_DEBUG_CONNECTED = 1,
  BTIF_DEBUG_DISCONNECTED
} btif_debug_conn_state_t;

// Report a connection state change
void btif_debug_conn_state(const bt_bdaddr_t bda, const btif_debug_conn_state_t state,
    const tGATT_DISCONN_REASON disconnect_reason);

void btif_debug_conn_dump(int fd);
Loading