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

Commit ba7adb3f authored by Duy Truong's avatar Duy Truong Committed by Charlie Boutier
Browse files

rootcanal: correctly handle error conditions in test command add_phy.

Make it so that AddPhy does not segfaults when called with no argument
and send a proper response when called with correct arguments.

Test: manually send add_phy commands with correct/incorrect arguments.
Bug: 241962982
Bug: 242184809
Ignore-AOSP-First: Cherry-picked from AOSP
Merged-In: Idfd84ed5e994469ac69ec30e408abe3662ec7290
Change-Id: Idfd84ed5e994469ac69ec30e408abe3662ec7290
parent 3b906ad8
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -188,15 +188,19 @@ void TestCommandHandler::Del(const vector<std::string>& args) {
}

void TestCommandHandler::AddPhy(const vector<std::string>& args) {
  if (args[0] == "LOW_ENERGY") {
  if (args.size() != 1) {
    response_string_ = "TestCommandHandler 'add_phy' takes one argument";
  } else if (args[0] == "LOW_ENERGY") {
    model_.AddPhy(Phy::Type::LOW_ENERGY);
    response_string_ = "TestCommandHandler 'add_phy' called with LOW_ENERGY";
  } else if (args[0] == "BR_EDR") {
    model_.AddPhy(Phy::Type::BR_EDR);
    response_string_ = "TestCommandHandler 'add_phy' called with BR_EDR";
  } else {
    response_string_ =
        "TestCommandHandler 'add_phy' with unrecognized type " + args[0];
    send_response_(response_string_);
  }
  send_response_(response_string_);
}

void TestCommandHandler::DelPhy(const vector<std::string>& args) {