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

Commit 0ee9f004 authored by Andre Eisenbach's avatar Andre Eisenbach Committed by Android Git Automerger
Browse files

am 85519120: Merge "Add ability to preserve existing snoop log" into lmp-dev

* commit '85519120':
  Add ability to preserve existing snoop log
parents 57b8fa40 85519120
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -5,6 +5,9 @@ BtSnoopLogOutput=false
# BtSnoop log output file
BtSnoopFileName=/sdcard/btsnoop_hci.log

# Preserve existing BtSnoop log before overwriting
BtSnoopSaveLog=false

# Enable trace level reconfiguration function
# Must be present before any TRC_ trace level settings
TraceConf=true
+2 −1
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
#define BT_HCI_LIB_H

#include <stdint.h>
#include <stdbool.h>
#include <sys/cdefs.h>
#include <sys/types.h>

@@ -187,7 +188,7 @@ typedef struct {
    int (*transmit_buf)(TRANSAC transac, char *p_buf, int len);

    /** Controls HCI logging on/off */
    int (*logging)(bt_hc_logging_state_t state, char *p_path);
    int (*logging)(bt_hc_logging_state_t state, char *p_path, bool save_existing);

    /** Closes the interface */
    void  (*cleanup)( void );
+1 −1
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@

#include "bt_hci_bdroid.h"

void btsnoop_open(const char *p_path);
void btsnoop_open(const char *p_path, const bool save_existing);
void btsnoop_close(void);

void btsnoop_capture(const HC_BT_HDR *p_buf, bool is_rcvd);
+2 −2
Original line number Diff line number Diff line
@@ -427,13 +427,13 @@ static int transmit_buf(TRANSAC transac, UNUSED_ATTR char *p_buf, UNUSED_ATTR in
}

/** Controls HCI logging on/off */
static int logging(bt_hc_logging_state_t state, char *p_path) {
static int logging(bt_hc_logging_state_t state, char *p_path, bool save_existing) {
  BTHCDBG("logging %d", state);

  if (state != BT_HC_LOGGING_ON)
    btsnoop_close();
  else if (p_path != NULL)
    btsnoop_open(p_path);
    btsnoop_open(p_path, save_existing);

  return BT_HC_STATUS_SUCCESS;
}
+9 −1
Original line number Diff line number Diff line
@@ -120,7 +120,7 @@ static void btsnoop_write_packet(packet_type_t type, const uint8_t *packet, bool
  utils_unlock();
}

void btsnoop_open(const char *p_path) {
void btsnoop_open(const char *p_path, const bool save_existing) {
  assert(p_path != NULL);
  assert(*p_path != '\0');

@@ -131,6 +131,14 @@ void btsnoop_open(const char *p_path) {
    return;
  }

  if (save_existing)
  {
    char fname_backup[266] = {0};
    strncat(fname_backup, p_path, 255);
    strcat(fname_backup, ".last");
    rename(p_path, fname_backup);
  }

  hci_btsnoop_fd = open(p_path,
                        O_WRONLY | O_CREAT | O_TRUNC,
                        S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH);
Loading