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

Commit a1b9a280 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "GD-Cert: Override parameters during cert test"

parents f661b747 76c87c4a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -263,6 +263,7 @@ cc_test {
        host: {
            srcs: [
                ":BluetoothHalTestSources_hci_rootcanal",
                ":BluetoothOsTestSources_host",
            ],
        },
        android: {
+3 −1
Original line number Diff line number Diff line
@@ -168,6 +168,8 @@ class GdDeviceBase(ABC):
                                                     '%s_%s_backing_logs.txt' % (self.type_identifier, self.label))
        if "--btsnoop=" not in " ".join(cmd):
            cmd.append("--btsnoop=%s" % os.path.join(self.log_path_base, '%s_btsnoop_hci.log' % self.label))
        if "--btconfig=" not in " ".join(cmd):
            cmd.append("--btconfig=%s" % os.path.join(self.log_path_base, '%s_bt_config.conf' % self.label))
        self.cmd = cmd
        self.environment = os.environ.copy()
        if "cert" in self.label:
+16 −6
Original line number Diff line number Diff line
@@ -14,28 +14,32 @@
 * limitations under the License.
 */

#include "stack_manager.h"

#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>

#include <csignal>
#include <cstring>
#include <memory>
#include <string>
#include <thread>

#include <client/linux/handler/exception_handler.h>
#include "stack_manager.h"

// clang-format off
#include <client/linux/handler/exception_handler.h>
#include <backtrace/Backtrace.h>
#include <backtrace/backtrace_constants.h>
// clang-format on

#include "common/init_flags.h"
#include "facade/grpc_root_server.h"
#include "hal/hci_hal_host_rootcanal.h"
#include "hal/snoop_logger.h"
#include "os/log.h"
#include "os/parameter_provider.h"
#include "os/system_properties.h"

using ::bluetooth::ModuleList;
using ::bluetooth::StackManager;
@@ -101,7 +105,7 @@ int main(int argc, const char** argv) {
  const std::string arg_rootcanal_port = "--rootcanal-port=";
  const std::string arg_signal_port = "--signal-port=";
  const std::string arg_btsnoop_path = "--btsnoop=";
  std::string btsnoop_path;
  const std::string arg_btconfig_path = "--btconfig=";
  for (int i = 1; i < argc; i++) {
    std::string arg = argv[i];
    if (arg.find(arg_grpc_root_server_port) == 0) {
@@ -117,8 +121,14 @@ int main(int argc, const char** argv) {
      HciHalHostRootcanalConfig::Get()->SetPort(std::stoi(port_number));
    }
    if (arg.find(arg_btsnoop_path) == 0) {
      btsnoop_path = arg.substr(arg_btsnoop_path.size());
      ::bluetooth::hal::SnoopLogger::SetFilePath(btsnoop_path);
      auto btsnoop_path = arg.substr(arg_btsnoop_path.size());
      ::bluetooth::os::ParameterProvider::OverrideSnoopLogFilePath(btsnoop_path);
      CHECK(::bluetooth::os::SetSystemProperty(
          ::bluetooth::hal::SnoopLogger::kBtSnoopLogModeProperty, ::bluetooth::hal::SnoopLogger::kBtSnoopLogModeFull));
    }
    if (arg.find(arg_btconfig_path) == 0) {
      auto btconfig_path = arg.substr(arg_btconfig_path.size());
      ::bluetooth::os::ParameterProvider::OverrideConfigFilePath(btconfig_path);
    }
    if (arg.find(arg_signal_port) == 0) {
      auto port_number = arg.substr(arg_signal_port.size());
+3 −16
Original line number Diff line number Diff line
@@ -95,7 +95,6 @@ void delete_btsnoop_files(const std::string& log_path) {

}  // namespace

std::string SnoopLogger::user_file_path_ = "";
const std::string SnoopLogger::kBtSnoopLogModeDisabled = "disabled";
const std::string SnoopLogger::kBtSnoopLogModeFiltered = "filtered";
const std::string SnoopLogger::kBtSnoopLogModeFull = "full";
@@ -171,10 +170,6 @@ void SnoopLogger::OpenNextSnoopLogFile() {
  }
}

void SnoopLogger::SetFilePath(std::string filename) {
  user_file_path_ = std::move(filename);
}

void SnoopLogger::Capture(const HciPacket& packet, Direction direction, PacketType type) {
  if (!is_enabled_) {
    // btsnoop disabled
@@ -288,17 +283,9 @@ std::string SnoopLogger::GetBtSnoopMode() {
  return btsnoop_mode;
}

std::string SnoopLogger::GetLogPath() {
  // Allow user override through SetFilePath() API
  auto log_path = os::ParameterProvider::SnoopLogFilePath();
  if (!user_file_path_.empty()) {
    log_path = user_file_path_;
  }
  return log_path;
}

const ModuleFactory SnoopLogger::Factory =
    ModuleFactory([]() { return new SnoopLogger(GetLogPath(), GetMaxPacketsPerFile(), GetBtSnoopMode()); });
const ModuleFactory SnoopLogger::Factory = ModuleFactory([]() {
  return new SnoopLogger(os::ParameterProvider::SnoopLogFilePath(), GetMaxPacketsPerFile(), GetBtSnoopMode());
});

}  // namespace hal
}  // namespace bluetooth
+0 −7
Original line number Diff line number Diff line
@@ -57,9 +57,6 @@ class SnoopLogger : public ::bluetooth::Module {
    uint32_t datalink_type;
  } __attribute__((__packed__));

  // Set File Path before module is started to ensure all packets are written to the right file
  static void SetFilePath(std::string filename);

  // Returns the maximum number of packets per file
  // Changes to this value is only effective after restarting Bluetooth
  static size_t GetMaxPacketsPerFile();
@@ -68,9 +65,6 @@ class SnoopLogger : public ::bluetooth::Module {
  // Changes to this values is only effective after restarting Bluetooth
  static std::string GetBtSnoopMode();

  // Get snoop log path based on current system configuration
  static std::string GetLogPath();

  // Has to be defined from 1 to 4 per btsnoop format
  enum PacketType {
    CMD = 1,
@@ -98,7 +92,6 @@ class SnoopLogger : public ::bluetooth::Module {
  void OpenNextSnoopLogFile();

 private:
  static std::string user_file_path_;
  std::string file_path_;
  std::ofstream btsnoop_ostream_;
  bool is_enabled_ = false;
Loading