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

Commit 06ec489e authored by Hansong Zhang's avatar Hansong Zhang
Browse files

SnoopLogger: Always flush for host build

When there is a crash, we can still grab the btsnoop log

Test: add a crash in cert stack and run cert/run_cert.sh
Change-Id: I9b33160d00420c39647e01919ede92a2349aecb6
parent 84341c48
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -113,6 +113,7 @@ class InternalHciCallbacks : public IBluetoothHciCallbacks {
}  // namespace

const std::string SnoopLogger::DefaultFilePath = "/data/misc/bluetooth/logs/btsnoop_hci.log";
const bool SnoopLogger::AlwaysFlush = false;

class HciHalHidl : public HciHal {
 public:
+1 −0
Original line number Diff line number Diff line
@@ -87,6 +87,7 @@ namespace bluetooth {
namespace hal {

const std::string SnoopLogger::DefaultFilePath = "/tmp/btsnoop_hci.log";
const bool SnoopLogger::AlwaysFlush = true;

class HciHalHostRootcanal : public HciHal {
 public:
+1 −0
Original line number Diff line number Diff line
@@ -119,6 +119,7 @@ void SnoopLogger::capture(const HciPacket& packet, Direction direction, PacketTy
                                    .type = static_cast<uint8_t>(type)};
  btsnoop_ostream_.write(reinterpret_cast<const char*>(&header), sizeof(btsnoop_packet_header_t));
  btsnoop_ostream_.write(reinterpret_cast<const char*>(packet.data()), packet.size());
  if (AlwaysFlush) btsnoop_ostream_.flush();
}

void SnoopLogger::ListDependencies(ModuleList* list) {
+2 −0
Original line number Diff line number Diff line
@@ -35,6 +35,8 @@ class SnoopLogger : public ::bluetooth::Module {
  static const std::string DefaultFilePath;
  // Set File Path before module is started to ensure all packets are written to the right file
  static void SetFilePath(const std::string& filename);
  // Flag to allow flush into persistent memory on every packet captured. This is enabled on host for debugging.
  static const bool AlwaysFlush;

  enum class PacketType {
    CMD = 1,