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

Commit 9e1f2fd5 authored by Chris Manton's avatar Chris Manton
Browse files

shim: Add default for HCI_STATUS helper

Bug: 185730737
Test: gd/cert/run
Tag: #refactor
BYPASS_LONG_LINES_REASON: Bluetooth likes 120 lines

Change-Id: I1681f65cfb3aa3cdfe38a1de987bf0aaf62d6c99
parent e36a7907
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -143,8 +143,6 @@ inline hci::Role ToHciRole(hci_role_t role) {

inline tHCI_STATUS ToLegacyHciErrorCode(hci::ErrorCode reason) {
  switch (reason) {
    case hci::ErrorCode::STATUS_UNKNOWN:
      return HCI_ERR_ILLEGAL_COMMAND;
    case hci::ErrorCode::SUCCESS:
      return HCI_SUCCESS;
    case hci::ErrorCode::UNKNOWN_HCI_COMMAND:
@@ -229,6 +227,10 @@ inline tHCI_STATUS ToLegacyHciErrorCode(hci::ErrorCode reason) {
    case hci::ErrorCode::CONNECTION_FAILED_ESTABLISHMENT:
      return static_cast<tHCI_STATUS>(
          hci::ErrorCode::CONNECTION_FAILED_ESTABLISHMENT);
    case hci::ErrorCode::STATUS_UNKNOWN:
      return HCI_ERR_UNDEFINED;
    default:
      return static_cast<tHCI_REASON>(reason);
  }
}

+12 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@
#include "include/hardware/bt_activity_attribution.h"
#include "main/shim/acl.h"
#include "main/shim/acl_legacy_interface.h"
#include "main/shim/helpers.h"
#include "main/test/common/main_handler.h"
#include "main/test/common/mock_entry.h"
#include "os/handler.h"
@@ -314,6 +315,17 @@ TEST_F(MainShimTest, Acl_Lifecycle) {
  acl = MakeAcl();
}

TEST_F(MainShimTest, helpers) {
  uint8_t reason = 0;
  do {
    hci::ErrorCode gd_error_code = static_cast<hci::ErrorCode>(reason);
    tHCI_STATUS legacy_code = ToLegacyHciErrorCode(gd_error_code);
    ASSERT_EQ(reason,
              static_cast<uint8_t>(ToLegacyHciErrorCode(gd_error_code)));
    ASSERT_EQ(reason, static_cast<uint8_t>(legacy_code));
  } while (++reason != 0);
}

TEST_F(MainShimTest, connect_and_disconnect) {
  hci::Address address({0x11, 0x22, 0x33, 0x44, 0x55, 0x66});