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

Commit a93e9c00 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Allow command complete and command status with opcode 0x0 anytime" am:...

Merge "Allow command complete and command status with opcode 0x0 anytime" am: 9b9ae133 am: 15ebe8a3

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/2005570

Change-Id: I778c005dd09fe79ff7710dc16df67e5f8fa9dc50
parents 43c98257 15ebe8a3
Loading
Loading
Loading
Loading
+20 −4
Original line number Diff line number Diff line
@@ -329,10 +329,26 @@ struct HciLayer::impl {
    ASSERT(event.IsValid());
    if (command_queue_.empty()) {
      auto event_code = event.GetEventCode();
      ASSERT_LOG(
          event_code != EventCode::COMMAND_COMPLETE && event_code != EventCode::COMMAND_STATUS,
          "Received %s without a waiting command (is the HAL sending commands, but not handling the events?)",
          EventCodeText(event_code).c_str());
      // BT Core spec 5.2 (Volume 4, Part E section 4.4) allows anytime
      // COMMAND_COMPLETE and COMMAND_STATUS with opcode 0x0 for flow control
      if (event_code == EventCode::COMMAND_COMPLETE) {
          auto view = CommandCompleteView::Create(event);
          ASSERT(view.IsValid());
          auto op_code = view.GetCommandOpCode();
          ASSERT_LOG(op_code == OpCode::NONE,
            "Received %s event with OpCode 0x%02hx (%s) without a waiting command"
            "(is the HAL sending commands, but not handling the events?)",
            EventCodeText(event_code).c_str(), op_code, OpCodeText(op_code).c_str());
      }
      if (event_code == EventCode::COMMAND_STATUS) {
          auto view = CommandStatusView::Create(event);
          ASSERT(view.IsValid());
          auto op_code = view.GetCommandOpCode();
          ASSERT_LOG(op_code == OpCode::NONE,
            "Received %s event with OpCode 0x%02hx (%s) without a waiting command"
            "(is the HAL sending commands, but not handling the events?)",
            EventCodeText(event_code).c_str(), op_code, OpCodeText(op_code).c_str());
      }
      std::unique_ptr<CommandView> no_waiting_command{nullptr};
      log_hci_event(no_waiting_command, event, module_.GetDependency<storage::StorageModule>());
    } else {