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

Commit c22191ee authored by Chris Manton's avatar Chris Manton
Browse files

Ensure stack is operational for connection history

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

Change-Id: Ibbc7b7c4bde847d6e4c763e7b73a15743f780e66
parent 5701afd8
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -1110,7 +1110,9 @@ void DumpsysAcl(int fd) {

  LOG_DUMPSYS_TITLE(fd, DUMPSYS_TAG);

  if (shim::Stack::GetInstance()->IsRunning()) {
    shim::Stack::GetInstance()->GetAcl()->DumpConnectionHistory(fd);
  }

  for (int i = 0; i < MAX_L2CAP_LINKS; i++) {
    const tACL_CONN& link = acl_cb.acl_db[i];
+25 −1
Original line number Diff line number Diff line
@@ -14,10 +14,12 @@
 *  limitations under the License.
 */

#include <fcntl.h>
#include <gmock/gmock.h>
#include <gtest/gtest.h>

#include <cstddef>
#include <cstdio>
#include <future>
#include <map>

@@ -87,7 +89,25 @@ struct bluetooth::hci::LeScanningManager::impl

namespace {
std::map<std::string, std::promise<uint16_t>> mock_function_handle_promise_map;

// Utility to provide a file descriptor for /dev/null when possible, but
// defaulting to STDERR when not possible.
class DevNullOrStdErr {
 public:
  DevNullOrStdErr() { fd_ = open("/dev/null", O_CLOEXEC | O_WRONLY); }
  ~DevNullOrStdErr() {
    if (fd_ != -1) {
      close(fd_);
    }
    fd_ = -1;
  }
  int Fd() const { return (fd_ == -1) ? STDERR_FILENO : fd_; }

 private:
  int fd_{-1};
};

}  // namespace

uint8_t mock_get_ble_acceptlist_size() { return 123; }

@@ -728,3 +748,7 @@ TEST_F(MainShimTestWithClassicConnection, read_extended_feature) {

  raw_connection_->read_remote_extended_features_function_ = {};
}

TEST_F(MainShimTest, acl_dumpsys) {
  MakeAcl()->Dump(std::make_unique<DevNullOrStdErr>()->Fd());
}