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

Commit 50933b2c authored by Zach Johnson's avatar Zach Johnson Committed by Gerrit Code Review
Browse files

Merge changes I2e971765,I3aa5c302

* changes:
  Format gd/storage with new clang-format
  Format gd/hal with new clang-format
parents f006ca5a 14c7f254
Loading
Loading
Loading
Loading
+24 −12
Original line number Diff line number Diff line
@@ -40,7 +40,9 @@ class HciHalFacadeService : public HciHalFacade::Service, public ::bluetooth::ha
    hal_->unregisterIncomingPacketCallback();
  }

  ::grpc::Status SendHciCommand(::grpc::ServerContext* context, const ::bluetooth::hal::HciCommandPacket* request,
  ::grpc::Status SendHciCommand(
      ::grpc::ServerContext* context,
      const ::bluetooth::hal::HciCommandPacket* request,
      ::google::protobuf::Empty* response) override {
    std::unique_lock<std::mutex> lock(mutex_);
    can_send_hci_command_ = false;
@@ -52,31 +54,41 @@ class HciHalFacadeService : public HciHalFacade::Service, public ::bluetooth::ha
    return ::grpc::Status::OK;
  }

  ::grpc::Status SendHciAcl(::grpc::ServerContext* context, const ::bluetooth::hal::HciAclPacket* request,
  ::grpc::Status SendHciAcl(
      ::grpc::ServerContext* context,
      const ::bluetooth::hal::HciAclPacket* request,
      ::google::protobuf::Empty* response) override {
    std::string req_string = request->payload();
    hal_->sendAclData(std::vector<uint8_t>(req_string.begin(), req_string.end()));
    return ::grpc::Status::OK;
  }

  ::grpc::Status SendHciSco(::grpc::ServerContext* context, const ::bluetooth::hal::HciScoPacket* request,
  ::grpc::Status SendHciSco(
      ::grpc::ServerContext* context,
      const ::bluetooth::hal::HciScoPacket* request,
      ::google::protobuf::Empty* response) override {
    std::string req_string = request->payload();
    hal_->sendScoData(std::vector<uint8_t>(req_string.begin(), req_string.end()));
    return ::grpc::Status::OK;
  }

  ::grpc::Status FetchHciEvent(::grpc::ServerContext* context, const ::google::protobuf::Empty* request,
  ::grpc::Status FetchHciEvent(
      ::grpc::ServerContext* context,
      const ::google::protobuf::Empty* request,
      ::grpc::ServerWriter<HciEventPacket>* writer) override {
    return pending_hci_events_.RunLoop(context, writer);
  };

  ::grpc::Status FetchHciAcl(::grpc::ServerContext* context, const ::google::protobuf::Empty* request,
  ::grpc::Status FetchHciAcl(
      ::grpc::ServerContext* context,
      const ::google::protobuf::Empty* request,
      ::grpc::ServerWriter<HciAclPacket>* writer) override {
    return pending_acl_events_.RunLoop(context, writer);
  };

  ::grpc::Status FetchHciSco(::grpc::ServerContext* context, const ::google::protobuf::Empty* request,
  ::grpc::Status FetchHciSco(
      ::grpc::ServerContext* context,
      const ::google::protobuf::Empty* request,
      ::grpc::ServerWriter<HciScoPacket>* writer) override {
    return pending_sco_events_.RunLoop(context, writer);
  };
+2 −2
Original line number Diff line number Diff line
@@ -16,11 +16,11 @@

#pragma once

#include <grpc++/grpc++.h>

#include <list>
#include <mutex>

#include <grpc++/grpc++.h>

#include "grpc/grpc_module.h"
#include "hal/hci_hal.h"

+1 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
 */

#include "hal/fuzz/fuzz_hci_hal.h"

#include "fuzz/helpers.h"
#include "hci/fuzz/status_vs_complete_commands.h"

+10 −17
Original line number Diff line number Diff line
@@ -14,16 +14,15 @@
 * limitations under the License.
 */

#include "hal/hci_hal.h"

#include <stdlib.h>
#include <vector>
#include <future>

#include <android/hardware/bluetooth/1.0/IBluetoothHci.h>
#include <android/hardware/bluetooth/1.0/IBluetoothHciCallbacks.h>
#include <android/hardware/bluetooth/1.0/types.h>
#include <stdlib.h>

#include <future>
#include <vector>

#include "hal/hci_hal.h"
#include "hal/snoop_logger.h"
#include "os/log.h"

@@ -50,8 +49,7 @@ android::sp<HciDeathRecipient> hci_death_recipient_ = new HciDeathRecipient();

class InternalHciCallbacks : public IBluetoothHciCallbacks {
 public:
  InternalHciCallbacks(SnoopLogger* btsnoop_logger)
      : btsnoop_logger_(btsnoop_logger) {
  InternalHciCallbacks(SnoopLogger* btsnoop_logger) : btsnoop_logger_(btsnoop_logger) {
    init_promise_ = new std::promise<void>();
  }

@@ -76,8 +74,7 @@ class InternalHciCallbacks : public IBluetoothHciCallbacks {

  Return<void> hciEventReceived(const hidl_vec<uint8_t>& event) {
    std::vector<uint8_t> received_hci_packet(event.begin(), event.end());
    btsnoop_logger_->capture(received_hci_packet, SnoopLogger::Direction::INCOMING,
                             SnoopLogger::PacketType::EVT);
    btsnoop_logger_->capture(received_hci_packet, SnoopLogger::Direction::INCOMING, SnoopLogger::PacketType::EVT);
    if (callback_ != nullptr) {
      callback_->hciEventReceived(std::move(received_hci_packet));
    }
@@ -86,8 +83,7 @@ class InternalHciCallbacks : public IBluetoothHciCallbacks {

  Return<void> aclDataReceived(const hidl_vec<uint8_t>& data) {
    std::vector<uint8_t> received_hci_packet(data.begin(), data.end());
    btsnoop_logger_->capture(received_hci_packet, SnoopLogger::Direction::INCOMING,
                             SnoopLogger::PacketType::ACL);
    btsnoop_logger_->capture(received_hci_packet, SnoopLogger::Direction::INCOMING, SnoopLogger::PacketType::ACL);
    if (callback_ != nullptr) {
      callback_->aclDataReceived(std::move(received_hci_packet));
    }
@@ -96,8 +92,7 @@ class InternalHciCallbacks : public IBluetoothHciCallbacks {

  Return<void> scoDataReceived(const hidl_vec<uint8_t>& data) {
    std::vector<uint8_t> received_hci_packet(data.begin(), data.end());
    btsnoop_logger_->capture(received_hci_packet, SnoopLogger::Direction::INCOMING,
                             SnoopLogger::PacketType::SCO);
    btsnoop_logger_->capture(received_hci_packet, SnoopLogger::Direction::INCOMING, SnoopLogger::PacketType::SCO);
    if (callback_ != nullptr) {
      callback_->scoDataReceived(std::move(received_hci_packet));
    }
@@ -177,9 +172,7 @@ class HciHalHidl : public HciHal {
  SnoopLogger* btsnoop_logger_;
};

const ModuleFactory HciHal::Factory = ModuleFactory([]() {
  return new HciHalHidl();
});
const ModuleFactory HciHal::Factory = ModuleFactory([]() { return new HciHalHidl(); });

}  // namespace hal
}  // namespace bluetooth
+2 −3
Original line number Diff line number Diff line
@@ -14,13 +14,12 @@
 * limitations under the License.
 */

#include "hal/hci_hal.h"
#include <gtest/gtest.h>

#include <chrono>
#include <future>

#include <gtest/gtest.h>

#include "hal/hci_hal.h"
#include "os/thread.h"

using ::bluetooth::os::Thread;
Loading